2 // Original: AliHLTConfMapper.cxx,v 1.26 2005/06/14 10:55:21 cvetan Exp $
4 //**************************************************************************
5 //* This file is property of and copyright by the ALICE HLT Project *
6 //* ALICE Experiment at CERN, All rights reserved. *
8 //* Primary Authors: Anders Vestbo, maintained by
9 //* Matthias Richter <Matthias.Richter@ift.uib.no> *
10 //* for The ALICE HLT Project. *
12 //* Permission to use, copy, modify and distribute this software and its *
13 //* documentation strictly for non-commercial purposes is hereby granted *
14 //* without fee, provided that the above copyright notice appears in all *
15 //* copies and that both the copyright notice and this permission notice *
16 //* appear in the supporting documentation. The authors make no claims *
17 //* about the suitability of this software for any purpose. It is *
18 //* provided "as is" without express or implied warranty. *
19 //**************************************************************************
21 /** @file AliHLTTPCConfMapper.cxx
22 @author Anders Vestbo, Matthias Richter
23 @date Conformal mapping base class.
30 #include "AliHLTTPCRootTypes.h"
31 #include "AliHLTTPCSpacePointData.h"
32 #include "AliHLTTPCLogging.h"
33 #include "AliHLTTPCVertex.h"
34 #include "AliHLTTPCConfMapTrack.h"
35 #include "AliHLTTPCConfMapPoint.h"
36 #include "AliHLTTPCTrackArray.h"
37 #include "AliHLTTPCTransform.h"
38 #include "AliHLTTPCConfMapper.h"
44 ClassImp(AliHLTTPCConfMapper)
46 AliHLTTPCConfMapper::AliHLTTPCConfMapper()
51 fVertexFinder(kFALSE),
54 fMaxDca(0.0), // no clue whether this is reasonable, but at least better than without initialization
60 fNumRowSegmentPlusOne(0),
61 fNumPhiSegmentPlusOne(0),
62 fNumEtaSegmentPlusOne(0),
63 fNumPhiEtaSegmentPlusOne(0),
65 fPhiHitsOutOfRange(0),
66 fEtaHitsOutOfRange(0),
73 fVertexConstraint(kTRUE),
86 AliHLTTPCConfMapper::~AliHLTTPCConfMapper()
97 void AliHLTTPCConfMapper::InitVolumes()
100 //Allocate volumes, set conformal coordinates and pointers.
102 //Should be done after setting the track parameters
104 fNumRowSegmentPlusOne = AliHLTTPCTransform::GetNRows();//NumRows[0]; //Maximum 32.
105 fNumPhiSegmentPlusOne = fNumPhiSegment+1;
106 fNumEtaSegmentPlusOne = fNumEtaSegment+1;
107 fNumPhiEtaSegmentPlusOne = fNumPhiSegmentPlusOne*fNumEtaSegmentPlusOne;
108 fBounds = fNumRowSegmentPlusOne * fNumPhiSegmentPlusOne * fNumEtaSegmentPlusOne;
112 fTrack = new AliHLTTPCTrackArray("AliHLTTPCConfMapTrack",10);
115 void AliHLTTPCConfMapper::Reset()
117 if(fVolume) delete [] fVolume;
119 if(fRow) delete [] fRow;
126 void AliHLTTPCConfMapper::InitSector(Int_t sector,Int_t *rowrange,Float_t *etarange)
127 { //sector means slice here
128 //Initialize tracker for tracking in a given sector.
129 //Resets track and hit arrays.
130 //Here it is also possible to specify a subsector, by defining
131 //rowrange[0]=innermost row;
132 //rowrange[1]=outermostrow;
133 //Finally you can specify etaslices to save time (assuming a good seed from TRD...)
135 //Define tracking area:
138 fRowMin = rowrange[0];
139 fRowMax = rowrange[1];
141 else //complete sector
144 fRowMax = AliHLTTPCTransform::GetNRows() - 1;
148 fEtaMin = etarange[0];
149 fEtaMax = sector < 18 ? etarange[1] : -etarange[1];
154 fEtaMax = sector < 18 ? 0.9 : -0.9;
157 //Set the angles to sector 2:
158 fPhiMin = -10*AliHLTTPCTransform::ToRad();//fParam->GetAngle(sector) - 10/todeg;
159 fPhiMax = 10*AliHLTTPCTransform::ToRad();//fParam->GetAngle(sector) + 10/todeg;
162 fMainVertexTracks = 0;
164 fEtaHitsOutOfRange=0;
165 fPhiHitsOutOfRange=0;
167 fNumRowSegment = fRowMax - fRowMin; //number of rows to be considered by tracker
168 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::InitSector","B-field")
169 <<"Tracker initializing with a magnetic field of "<<AliHLTTPCTransform::GetBField()<<ENDLOG;
174 Bool_t AliHLTTPCConfMapper::ReadHits(UInt_t count, AliHLTTPCSpacePointData* hits )
177 if (fHit.size()<fClustersUnused+count) fHit.resize(fClustersUnused+count);
178 assert(fHit.size()>=fClustersUnused+count);
179 for (Int_t i=0;(UInt_t)i<count;i++)
181 fHit[i+fClustersUnused].Reset();
182 fHit[i+fClustersUnused].Read(hits[i]);
184 fClustersUnused += count;
186 LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::ReadHits","#hits")
187 <<AliHLTTPCLog::kDec<<"#hits: "<<count<<" total: "<<fClustersUnused<<ENDLOG;
192 void AliHLTTPCConfMapper::SetPointers()
194 //Check if there are not enough clusters to make a track in this sector
195 //Can happen in pp events.
197 if(fClustersUnused < fMinPoints[fVertexConstraint])
200 //Allocate detector volumes
202 LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
203 "Allocating "<<fBounds*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fVolume"<<ENDLOG;
204 fVolume = new AliHLTTPCConfMapContainer[fBounds];
208 LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
209 "Allocating "<<fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fRow"<<ENDLOG;
210 fRow = new AliHLTTPCConfMapContainer[fNumRowSegmentPlusOne];
213 memset(fVolume,0,fBounds*sizeof(AliHLTTPCConfMapContainer));
214 memset(fRow,0,fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer));
216 Float_t phiSlice = (fPhiMax-fPhiMin)/fNumPhiSegment;
217 Float_t etaSlice = (fEtaMax-fEtaMin)/fNumEtaSegment;
220 Int_t localcounter=0;
221 assert((int)fHit.size()>=fClustersUnused);
222 for(Int_t j=0; j<fClustersUnused; j++)
224 AliHLTTPCConfMapPoint *thisHit = &(fHit[j]);
226 thisHit->Setup(fVertex);
228 Int_t localrow = thisHit->GetPadRow();
230 if(localrow < fRowMin || localrow > fRowMax)
234 thisHit->SetPhiIndex((Int_t)((thisHit->GetPhi()-fPhiMin)/phiSlice +1));
236 if(thisHit->GetPhiIndex()<1 || thisHit->GetPhiIndex()>fNumPhiSegment)
238 //cout << "Phiindex: " << thisHit->phiIndex << " " << thisHit->GetPhi() << endl;
239 fPhiHitsOutOfRange++;
243 thisHit->SetEtaIndex((Int_t)((thisHit->GetEta()-fEtaMin)/etaSlice + 1));
244 if(thisHit->GetEtaIndex()<1 || thisHit->GetEtaIndex()>fNumEtaSegment)
246 //cout << "Etaindex: " << thisHit->etaIndex << " " << thisHit->GetEta() << endl;
247 fEtaHitsOutOfRange++;
252 volumeIndex = (localrow-fRowMin)*fNumPhiEtaSegmentPlusOne +
253 thisHit->GetPhiIndex()*fNumEtaSegmentPlusOne+thisHit->GetEtaIndex();
255 if(fVolume[volumeIndex].first == NULL)
256 fVolume[volumeIndex].first = (void *)thisHit;
258 ((AliHLTTPCConfMapPoint *)fVolume[volumeIndex].last)->SetNextVolumeHit(thisHit);
259 fVolume[volumeIndex].last = (void *)thisHit;
263 if(fRow[(localrow-fRowMin)].first == NULL)
264 fRow[(localrow-fRowMin)].first = (void *)thisHit;
266 ((AliHLTTPCConfMapPoint *)(fRow[(localrow-fRowMin)].last))->SetNextRowHit(thisHit);
267 fRow[(localrow-fRowMin)].last = (void *)thisHit;
270 if(fClustersUnused>0 && localcounter==0)
271 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::SetPointers","Parameters")
272 <<AliHLTTPCLog::kDec<<"No points passed to track finder, hits out of range: "
273 <<fEtaHitsOutOfRange+fPhiHitsOutOfRange<<ENDLOG;
275 Int_t hits_accepted=fClustersUnused-(fEtaHitsOutOfRange+fPhiHitsOutOfRange);
276 LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::SetPointers","Setup")
277 <<"Setup finished, hits out of range: "<<fEtaHitsOutOfRange+fPhiHitsOutOfRange
278 <<" hits accepted "<<hits_accepted<<ENDLOG;
281 void AliHLTTPCConfMapper::MainVertexTrackingA()
283 //Tracking with vertex constraint.
285 if(!fParamSet[(Int_t)kTRUE])
287 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
288 "Tracking parameters not set!"<<ENDLOG;
292 Double_t initCpuTime,cpuTime;
293 initCpuTime = CpuTime();
296 SetVertexConstraint(true);
297 cpuTime = CpuTime() - initCpuTime;
299 LOG(AliHLTTPCLog::kBenchmark,"AliHLTTPCConfMapper::MainVertexTrackingA","Timing")
300 <<AliHLTTPCLog::kDec<<"Setup finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
304 void AliHLTTPCConfMapper::MainVertexTrackingB()
306 //Tracking with vertex constraint.
308 if(!fParamSet[(Int_t)kTRUE])
310 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
311 "Tracking parameters not set!"<<ENDLOG;
314 Double_t initCpuTime,cpuTime;
315 initCpuTime = CpuTime();
319 cpuTime = CpuTime() - initCpuTime;
321 LOG(AliHLTTPCLog::kBenchmark,"AliHLTTPCConfMapper::MainVertexTrackingB","Timing")
322 <<AliHLTTPCLog::kDec<<"Main Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
325 void AliHLTTPCConfMapper::MainVertexTracking()
327 //Tracking with vertex constraint.
329 if(!fParamSet[(Int_t)kTRUE])
331 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
332 "Tracking parameters not set!"<<ENDLOG;
336 Double_t initCpuTime,cpuTime;
337 initCpuTime = CpuTime();
341 SetVertexConstraint(true);
345 cpuTime = CpuTime() - initCpuTime;
347 LOG(AliHLTTPCLog::kBenchmark,"AliHLTTPCConfMapper::MainVertexTracking","Timing")<<AliHLTTPCLog::kDec<<
348 "Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
353 void AliHLTTPCConfMapper::NonVertexTracking()
355 //Tracking with no vertex constraint. This should be called after doing MainVertexTracking,
356 //in order to do tracking on the remaining clusters.
357 //The conformal mapping is now done with respect to the first cluster
358 //assosciated with this track.
360 if(!fParamSet[(Int_t)kFALSE])
362 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::NonVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
363 "Tracking parameters not set!"<<ENDLOG;
367 SetVertexConstraint(false);
369 SetPointers(); //To be able to do only nonvertextracking (more testing)
372 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::NonVertexTracking","ntracks")<<AliHLTTPCLog::kDec<<
373 "Number of nonvertex tracks found: "<<(fNTracks-fMainVertexTracks)<<ENDLOG;
377 void AliHLTTPCConfMapper::MainVertexSettings(Int_t trackletlength, Int_t tracklength,
378 Int_t rowscopetracklet, Int_t rowscopetrack,
379 Double_t maxphi,Double_t maxeta)
381 //Settings for main vertex tracking. The cuts are:
382 //TrackletLength: #hits on segment, before trying to build a track
383 //TrackLength: Minimum hits on a track
384 //RowScopeTracklet: Row search range for segments
385 //RowScopeTrack: Row search range for tracks
387 SetTrackletLength(trackletlength,(Bool_t)true);
388 SetRowScopeTracklet(rowscopetracklet, (Bool_t) true);
389 SetRowScopeTrack(rowscopetrack, (Bool_t) true);
390 SetMinPoints(tracklength,(Bool_t)true);
396 void AliHLTTPCConfMapper::NonVertexSettings(Int_t trackletlength, Int_t tracklength,
397 Int_t rowscopetracklet, Int_t rowscopetrack)
399 //set parameters for non-vertex tracking
400 SetTrackletLength(trackletlength,(Bool_t)false);
401 SetRowScopeTracklet(rowscopetracklet, (Bool_t)false);
402 SetRowScopeTrack(rowscopetrack, (Bool_t)false);
403 SetMinPoints(tracklength,(Bool_t)false);
404 SetParamDone(kFALSE);
407 void AliHLTTPCConfMapper::SetTrackCuts(Double_t hitChi2Cut, Double_t goodHitChi2, Double_t trackChi2Cut,Int_t maxdist,Bool_t vertexconstraint)
409 //Settings for tracks. The cuts are:
410 //HitChi2Cut: Maximum hit chi2
411 //goodHitChi2: Chi2 to stop look for next hit
412 //trackChi2Cut: Maximum track chi2
413 //maxdist: Maximum distance between two clusters when forming segments
415 SetHitChi2Cut(hitChi2Cut,vertexconstraint);
416 SetGoodHitChi2(goodHitChi2,vertexconstraint);
417 SetTrackChi2Cut(trackChi2Cut,vertexconstraint);
418 SetMaxDist(maxdist,vertexconstraint);
421 void AliHLTTPCConfMapper::SetTrackletCuts(Double_t maxangle,Double_t goodDist, Bool_t vc)
423 //Sets cuts of tracklets. Right now this is only:
424 //maxangle: Maximum angle when forming segments (if trackletlength > 2)
427 SetMaxAngleTracklet(maxangle, vc);
430 void AliHLTTPCConfMapper::ClusterLoop()
432 //Loop over hits, starting at outermost padrow, and trying to build segments.
434 //Check if there are not enough clusters to make a track in this sector
435 //Can happen in pp events.
436 if(fClustersUnused < fMinPoints[fVertexConstraint])
439 Int_t rowsegm,lastrow = fRowMin + fMinPoints[fVertexConstraint];
440 AliHLTTPCConfMapPoint *hit;
442 //Loop over rows, and try to create tracks from the hits.
443 //Starts at the outermost row, and loops as long as a track can be build, due to length.
445 for(rowsegm = fRowMax; rowsegm >= lastrow; rowsegm--)
447 if(fRow[(rowsegm-fRowMin)].first && ((AliHLTTPCConfMapPoint*)fRow[(rowsegm-fRowMin)].first)->GetPadRow() < fRowMin + 1)
450 for(hit = (AliHLTTPCConfMapPoint*)fRow[(rowsegm-fRowMin)].first; hit!=0; hit=hit->GetNextRowHit())
452 if(hit->GetUsage() == true)
463 void AliHLTTPCConfMapper::CreateTrack(AliHLTTPCConfMapPoint *hit)
465 //Tries to create a track from the initial hit given by ClusterLoop()
467 AliHLTTPCConfMapPoint *closesthit = NULL;
468 AliHLTTPCConfMapTrack *track = NULL;
471 Int_t tracks = fNTracks;
474 track = (AliHLTTPCConfMapTrack*)fTrack->NextTrack();
476 //reset hit parameters:
479 UInt_t *trackhitnumber = track->GetHitNumbers();
481 //set conformal coordinates if we are looking for non vertex tracks
482 if(!fVertexConstraint)
484 hit->SetAllCoord(hit);
487 //fill fit parameters of initial track:
488 track->UpdateParam(hit); //here the number of hits is incremented.
489 trackhitnumber[track->GetNumberOfPoints()-1] = hit->GetHitNumber();
494 for(point=1; point<fTrackletLength[fVertexConstraint]; point++)
496 if((closesthit = GetNextNeighbor(hit)))
499 // Calculate track length in sz plane
500 dx = ((AliHLTTPCConfMapPoint*)closesthit)->GetX() - ((AliHLTTPCConfMapPoint*)hit)->GetX();
501 dy = ((AliHLTTPCConfMapPoint*)closesthit)->GetY() - ((AliHLTTPCConfMapPoint*)hit)->GetY();
502 //track->fLength += (Double_t)sqrt ( dx * dx + dy * dy ) ;
503 Double_t length = track->GetLength()+(Double_t)sqrt ( dx * dx + dy * dy );
504 track->SetLength(length);
506 //closesthit->SetS(track->fLength);
507 closesthit->SetS(track->GetLength());
509 //update fit parameters
510 track->UpdateParam(closesthit);
511 trackhitnumber[track->GetNumberOfPoints()-1] = closesthit->GetHitNumber();
517 //closest hit does not exist:
518 track->DeleteCandidate();
519 fTrack->RemoveLast();
521 point = fTrackletLength[fVertexConstraint];
525 //tracklet is long enough to be extended to a track
526 if(track->GetNumberOfPoints() == fTrackletLength[fVertexConstraint])
529 track->SetProperties(true);
531 if(TrackletAngle(track) > fMaxAngleTracklet[fVertexConstraint])
532 {//proof if the first points seem to be a beginning of a track
533 track->SetProperties(false);
534 track->DeleteCandidate();
535 fTrack->RemoveLast();
539 else//good tracklet ->proceed, follow the trackfit
543 //define variables to keep the total chi:
544 Double_t xyChi2 = track->GetChiSq1();
545 Double_t szChi2 = track->GetChiSq2();
547 for(point = fTrackletLength[fVertexConstraint]; point <= fNumRowSegment; point++)
549 track->SetChiSq1(fHitChi2Cut[fVertexConstraint]);
550 closesthit = GetNextNeighbor((AliHLTTPCConfMapPoint*)track->GetLastHit(),track);
555 Double_t lxyChi2 = track->GetChiSq1()-track->GetChiSq2();
557 closesthit->SetXYChi2(lxyChi2);
559 //update track length:
560 track->SetLength(closesthit->GetS());
561 szChi2 += track->GetChiSq2();
562 closesthit->SetSZChi2(track->GetChiSq2());
564 track->UpdateParam(closesthit);
565 trackhitnumber[track->GetNumberOfPoints()-1] = closesthit->GetHitNumber();
567 //add closest hit to track
568 closesthit->SetUsage(true);
569 closesthit->SetTrackNumber(tracks-1);
575 //closest hit does not exist
576 point = fNumRowSegment; //continue with next hit in segment
582 track->SetChiSq1(xyChi2);
583 track->SetChiSq2(szChi2);
584 Double_t normalizedchi2 = (track->GetChiSq1()+track->GetChiSq2())/track->GetNumberOfPoints();
586 //remove tracks with not enough points already now
587 if(track->GetNumberOfPoints() < fMinPoints[fVertexConstraint] || normalizedchi2 > fTrackChi2Cut[fVertexConstraint])
589 track->SetProperties(false);
591 track->DeleteCandidate();
592 fTrack->RemoveLast();
598 fClustersUnused -= track->GetNumberOfPoints();
599 track->ComesFromMainVertex(fVertexConstraint);
600 //mark track as main vertex track or not
601 track->SetSector(2); //only needed for testing purposes.
602 track->SetRowRange(fRowMin,fRowMax);
604 if(fVertexConstraint)
615 AliHLTTPCConfMapPoint *AliHLTTPCConfMapper::GetNextNeighbor(AliHLTTPCConfMapPoint *starthit,
616 AliHLTTPCConfMapTrack *track)
618 //When forming segments: Finds closest hit to input hit
619 //When forming tracks: Find closest hit to track fit.
621 Double_t dist,closestdist = fMaxDist[fVertexConstraint];
623 AliHLTTPCConfMapPoint *hit = NULL;
624 AliHLTTPCConfMapPoint *closesthit = NULL;
632 Int_t maxrow = starthit->GetPadRow()-1;
635 if(track) //finding hit close to trackfit
637 minrow = starthit->GetPadRow()-fRowScopeTrack[fVertexConstraint];
641 minrow = starthit->GetPadRow()-fRowScopeTracklet[fVertexConstraint];
645 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};
646 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};
651 return 0; //reached the last padrow under consideration
656 for(subrowsegm=maxrow; subrowsegm>=minrow; subrowsegm--)
658 //loop over subsegments, in the order defined above.
659 for(Int_t i=0; i<9; i++)
661 subphisegm = starthit->GetPhiIndex() + loopphi[i];
663 if(subphisegm < 0 || subphisegm >= fNumPhiSegment)
667 subphisegm += fNumPhiSegment;
669 else if(subphisegm >=fNumPhiSegment)
670 subphisegm -= fNumPhiSegment;
672 //loop over sub eta segments
674 subetasegm = starthit->GetEtaIndex() + loopeta[i];
676 if(subetasegm < 0 || subetasegm >=fNumEtaSegment)
677 continue;//segment exceeds bounds->skip it
679 //loop over hits in this sub segment:
680 volumeIndex=(subrowsegm-fRowMin)*fNumPhiEtaSegmentPlusOne +
681 subphisegm*fNumEtaSegmentPlusOne + subetasegm;
685 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::GetNextNeighbor","Memory")<<AliHLTTPCLog::kDec<<
686 "VolumeIndex error "<<volumeIndex<<ENDLOG;
689 assert(fVolume!=NULL);
690 for(hit = (AliHLTTPCConfMapPoint*)fVolume[volumeIndex].first;
691 hit!=0; hit = hit->GetNextVolumeHit())
695 {//hit was not used before
697 //set conformal mapping if looking for nonvertex tracks:
698 if(!fVertexConstraint)
700 hit->SetAllCoord(starthit);
703 if(track)//track search - look for nearest neighbor to extrapolated track
705 if (fVertexConstraint) {
706 if(!VerifyRange(starthit,hit))
709 testhit = EvaluateHit(starthit,hit,track);
711 if(testhit == 0)//chi2 not good enough, keep looking
713 else if(testhit==2)//chi2 good enough, return it
716 closesthit = hit;//chi2 acceptable, but keep looking
720 else //tracklet search, look for nearest neighbor
723 if((dist=CalcDistance(starthit,hit)) < closestdist)
725 if (fVertexConstraint) {
726 if(!VerifyRange(starthit,hit))
732 //if this hit is good enough, return it:
733 if(closestdist < fGoodDist)
737 continue;//sub hit was farther away than a hit before
741 }//hit not used before
743 else continue; //sub hit was used before
745 }//loop over hits in sub segment
747 }//loop over sub segments
754 if(closesthit)// && closestdist < mMaxDist)
760 Int_t AliHLTTPCConfMapper::EvaluateHit(AliHLTTPCConfMapPoint *starthit,AliHLTTPCConfMapPoint *hit,AliHLTTPCConfMapTrack *track)
762 //Check if space point gives a fit with acceptable chi2.
764 Double_t temp,dxy,lchi2,dx,dy,slocal,dsz,lszChi2;
765 temp = (track->GetA2Xy()*hit->GetXprime()-hit->GetYprime()+track->GetA1Xy());
766 dxy = temp*temp/(track->GetA2Xy()*track->GetA2Xy() + 1.);
769 lchi2 = (dxy*hit->GetXYWeight());
771 if(lchi2 > track->GetChiSq1())//chi2 was worse than before.
774 //calculate s and the distance hit-line
775 dx = starthit->GetX()-hit->GetX();
776 dy = starthit->GetY()-hit->GetY();
777 //slocal = track->fLength+sqrt(dx*dx+dy*dy);
778 slocal = track->GetLength()+sqrt(dx*dx+dy*dy);
780 temp = (track->GetA2Sz()*slocal-hit->GetZ()+track->GetA1Sz());
781 dsz = temp*temp/(track->GetA2Sz()*track->GetA2Sz()+1);
784 lszChi2 = dsz*hit->GetZWeight();
788 //check whether chi2 is better than previous one:
789 if(lchi2 < track->GetChiSq1())
791 track->SetChiSq1(lchi2);
792 track->SetChiSq2(lszChi2);
796 //if chi2 good enough, stop here:
797 if(lchi2 < fGoodHitChi2[fVertexConstraint])
807 Double_t AliHLTTPCConfMapper::CalcDistance(const AliHLTTPCConfMapPoint *hit1,const AliHLTTPCConfMapPoint *hit2) const
809 //Return distance between two clusters, defined by Pablo
811 Double_t phidiff = fabs( hit1->GetPhi() - hit2->GetPhi() );
812 if (phidiff > AliHLTTPCTransform::Pi()) phidiff = AliHLTTPCTransform::TwoPi() - phidiff;
814 return AliHLTTPCTransform::ToDeg()*fabs((Float_t)((hit1->GetPadRow() - hit2->GetPadRow()) *
815 (phidiff + fabs( hit1->GetEta() - hit2->GetEta()))));
818 Bool_t AliHLTTPCConfMapper::VerifyRange(const AliHLTTPCConfMapPoint *hit1,const AliHLTTPCConfMapPoint *hit2) const
820 //Check if the hit are within reasonable range in phi and eta
821 Double_t dphi,deta;//maxphi=0.1,maxeta=0.1;
822 dphi = fabs(hit1->GetPhi() - hit2->GetPhi());
823 if(dphi > AliHLTTPCTransform::Pi()) dphi = fabs(AliHLTTPCTransform::TwoPi() - dphi);
824 if(dphi > fMaxPhi) return false;
826 deta = fabs(hit1->GetEta() - hit2->GetEta());
827 if(deta > fMaxEta) return false;
833 Double_t AliHLTTPCConfMapper::TrackletAngle(AliHLTTPCConfMapTrack *track,Int_t n) const
835 // Returns the angle 'between' the last three points (started at point number n) on this track.
837 if(n > track->GetNumberOfPoints())
838 n = track->GetNumberOfPoints();
843 Double_t x1[2]={0,0};
844 Double_t x2[2]={0,0};
845 Double_t x3[2]={0,0};
846 Double_t angle1,angle2;
848 for(track->StartLoop(); track->LoopDone(); track->GetNextHit())
850 AliHLTTPCConfMapPoint *p = (AliHLTTPCConfMapPoint*)track->GetCurrentHit();
851 if( (n-1) == counter)
856 else if( (n-2) == counter)
861 else if( (n-3) == counter)
869 angle1 = atan2(x2[1]-x3[1],x2[0]-x3[0]);
870 angle2 = atan2(x1[1]-x2[1],x1[0]-x2[0]);
872 return fabs(angle1-angle2);
877 Double_t angle1,angle2;
878 TObjArray *hits = track->GetHits();
880 if (n > track->GetNumberOfPoints()) {
881 n = track->GetNumberOfPoints();
888 x1[0] = ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetX() - ((AliHLTTPCConfMapPoint *)hits->At(n-3))->GetX();
889 x1[1] = ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetY() - ((AliHLTTPCConfMapPoint *)hits->At(n-3))->GetY();
891 x2[0] = ((AliHLTTPCConfMapPoint *)hits->At(n-1))->GetX() - ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetX();
892 x2[1] = ((AliHLTTPCConfMapPoint *)hits->At(n-1))->GetY() - ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetY();
894 angle1 = atan2(x1[1],x1[0]);
895 angle2 = atan2(x2[1],x1[0]);
896 return fabs(angle1-angle2);
900 Int_t AliHLTTPCConfMapper::FillTracks()
902 //Fill track parameters. Which basically means do a fit of helix in real space,
903 //which should be done in order to get nice tracks.
905 Int_t numoftracks = fNTracks;
908 LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::FillTracks","fNTracks")<<AliHLTTPCLog::kDec<<
909 "No tracks found!!"<<ENDLOG;
913 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::FillTracks","fNTracks")<<AliHLTTPCLog::kDec<<
914 "Number of found tracks: "<<fNTracks<<ENDLOG;
917 for(Int_t i=0; i<numoftracks; i++)
919 AliHLTTPCConfMapTrack *track = (AliHLTTPCConfMapTrack*)fTrack->GetTrack(i);
920 track->Fill(fVertex,fMaxDca);
925 Double_t AliHLTTPCConfMapper::CpuTime()
927 //Return the Cputime in seconds.
929 gettimeofday( &tv, NULL );
930 return tv.tv_sec+(((Double_t)tv.tv_usec)/1000000.);