]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/src/AliL3ConfMapper.cxx
Some changes to make is possible to run several events, and also some settings for...
[u/mrichter/AliRoot.git] / HLT / src / AliL3ConfMapper.cxx
CommitLineData
b661165c 1// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
2//*-- Copyright &copy ASV
3
108615fc 4#include <iostream.h>
5#include <time.h>
6#include <math.h>
7#include "AliL3ConfMapper.h"
8
9#include "AliL3Logging.h"
10#include "AliL3Transform.h"
11#include "AliL3Vertex.h"
12#include "AliL3ConfMapTrack.h"
13#include "AliL3ConfMapPoint.h"
14#include "AliL3TrackArray.h"
15
b661165c 16//_____________________________________________________________
17// AliL3ConfMapper
108615fc 18//
b661165c 19// Conformal mapping base class
108615fc 20//
108615fc 21ClassImp(AliL3ConfMapper)
22
23Double_t AliL3ConfMapper::pi=3.14159265358979323846;
24Double_t AliL3ConfMapper::twopi=2*pi;
25Double_t AliL3ConfMapper::todeg=180./pi;
26
27AliL3ConfMapper::AliL3ConfMapper()
28{
29 //Default constructor
30 fVertex = NULL;
31 fTrack = NULL;
32 fHit = NULL;
108615fc 33 fVolume = NULL;
34 fRow = NULL;
35 fBench = (Bool_t)true;
36 fParamSet = (Bool_t)false;
37 fVertexConstraint = (Bool_t)true;
38}
39
40
41AliL3ConfMapper::~AliL3ConfMapper()
42{
43 // Destructor.
44
45 if(fVolume) {
46 delete [] fVolume;
47 }
48 if(fRow) {
49 delete [] fRow;
50 }
108615fc 51 if(fHit) {
52 delete [] fHit;
53 }
54 if(fTrack) {
55 delete fTrack;
56 }
57
58}
59
60void AliL3ConfMapper::InitSector(Int_t sector,Int_t *rowrange,Float_t *etarange)
61{
62 //Initialize tracker for tracking in a given sector.
63 //Resets track and hit arrays.
64 //Here it is also possible to specify a subsector, by defining
65 //rowrange[0]=innermost row;
66 //rowrange[1]=outermostrow;
67 //Finally you can specify etaslices to save time (assuming a good seed from TRD...)
68
69 if(fHit)
70 {
71 delete [] fHit;
72 }
73
108615fc 74 if(fTrack)
75 {
76 delete fTrack;
77 }
78
79 //Define tracking area:
80 if(rowrange)
81 {
82 fRowMin = rowrange[0];
83 fRowMax = rowrange[1];
84 }
85 else //complete sector
86 {
87 fRowMin = 0;
ae97a0b9 88 fRowMax = 175;
108615fc 89 }
90 if(etarange)
91 {
92 fEtaMin = etarange[0];
93 fEtaMax = etarange[1];
94 }
95 else
96 {
97 fEtaMin = 0;
98 fEtaMax = sector < 18 ? 0.9 : -0.9;
99 }
100
101 //Set the angles to sector 2:
102 fPhiMin = -1.*10/todeg;//fParam->GetAngle(sector) - 10/todeg;
103 fPhiMax = 10/todeg;//fParam->GetAngle(sector) + 10/todeg;
104
105 //rotation angles for sector 2:
106 //cos: 0.766044 sin: 0.642788
107
108 Int_t max_num_of_tracks = 3000;
8c29ba9c 109 Int_t max_num_of_hits = 150000;
108615fc 110
108615fc 111 fHit = new AliL3ConfMapPoint[max_num_of_hits];
108615fc 112 fTrack = new AliL3TrackArray("AliL3ConfMapTrack",max_num_of_tracks);
113
114 nTracks=0;
115 fClustersUnused = 0;
116
117 fNumRowSegment = fRowMax - fRowMin; //number of rows to be considered by tracker
118
119}
120
121
122
123Bool_t AliL3ConfMapper::ReadHits(UInt_t count, AliL3SpacePointData* hits )
124{
108615fc 125 Int_t nhit=(Int_t)count;
a9d69a4d 126 for (Int_t i=0;i<nhit;i++)
127 fHit[i].ReadHits(&(hits[i]));
108615fc 128 fClustersUnused += nhit;
129 LOG(AliL3Log::kInformational,"AliL3ConfMapper::ReadHits","#hits")<<AliL3Log::kDec
130 <<"hit_counter: "<<nhit<<" count: "<<count<<ENDLOG;
131
132 return true;
133}
134
135
136void AliL3ConfMapper::SetPointers()
137{
138 //Data organization.
139 //Allocate volumes, set conformal coordinates and pointers.
ae97a0b9 140 fNumRowSegmentPlusOne = 176;//fNumRowSegment+1;
108615fc 141 fNumPhiSegmentPlusOne = fNumPhiSegment+1;
142 fNumEtaSegmentPlusOne = fNumEtaSegment+1;
143 fNumPhiEtaSegmentPlusOne = fNumPhiSegmentPlusOne*fNumEtaSegmentPlusOne;
144 fBounds = fNumRowSegmentPlusOne * fNumPhiSegmentPlusOne * fNumEtaSegmentPlusOne;
145
146 //Allocate volumes:
147 if(fVolume) delete [] fVolume;
148 if(fRow) delete [] fRow;
149
150 LOG(AliL3Log::kInformational,"AliL3ConfMapper::SetPointers","Memory")<<AliL3Log::kDec<<
151 "Allocating "<<fBounds*sizeof(AliL3ConfMapContainer)<<" Bytes to fVolume"<<ENDLOG;
152 LOG(AliL3Log::kInformational,"AliL3ConfMapper::SetPointers","Memory")<<AliL3Log::kDec<<
153 "Allocating "<<fNumRowSegmentPlusOne*sizeof(AliL3ConfMapContainer)<<" Bytes to fRow"<<ENDLOG;
154
155 fVolume = new AliL3ConfMapContainer[fBounds];
156 fRow = new AliL3ConfMapContainer[fNumRowSegmentPlusOne];
157
158 //set volumes to zero:
159 memset(fVolume,0,fBounds*sizeof(AliL3ConfMapContainer));
160 memset(fRow,0,fNumRowSegmentPlusOne*sizeof(AliL3ConfMapContainer));
161
162 Float_t phiSlice = (fPhiMax-fPhiMin)/fNumPhiSegment;
163 Float_t etaSlice = (fEtaMax-fEtaMin)/fNumEtaSegment;
164
165 Int_t volumeIndex;
e0e14b24 166 Int_t local_counter=0;
108615fc 167 for(Int_t j=0; j<fClustersUnused; j++)
168 {
169
170 //AliL3ConfMapPoint *thisHit = (AliL3ConfMapPoint*)fHit->At(j);
a9d69a4d 171 AliL3ConfMapPoint *thisHit = &(fHit[j]);
108615fc 172
173 thisHit->Setup(fVertex);
174
175 Int_t localrow = thisHit->GetPadRow();
176
177 //reset pointers:
178 thisHit->nextVolumeHit=thisHit->nextRowHit=0;
179
180 if(localrow < fRowMin || localrow > fRowMax)
181 continue;
182
183
184 //Get indexes:
185 thisHit->phiIndex=(Int_t)((thisHit->GetPhi()-fPhiMin)/phiSlice +1);
186
187 if(thisHit->phiIndex<1 || thisHit->phiIndex>fNumPhiSegment)
188 {
189 fPhiHitsOutOfRange++;
190 continue;
191 }
192
193 thisHit->etaIndex=(Int_t)((thisHit->GetEta()-fEtaMin)/etaSlice + 1);
194 if(thisHit->etaIndex<1 || thisHit->etaIndex>fNumEtaSegment)
195 {
196 fEtaHitsOutOfRange++;
197 continue;
198 }
e0e14b24 199 local_counter++;
200
108615fc 201 //set volume pointers
202 volumeIndex = localrow*fNumPhiEtaSegmentPlusOne+thisHit->phiIndex*fNumEtaSegmentPlusOne+thisHit->etaIndex;
203 if(fVolume[volumeIndex].first == NULL)
204 fVolume[volumeIndex].first = (void *)thisHit;
205 else
206 ((AliL3ConfMapPoint *)fVolume[volumeIndex].last)->nextVolumeHit=thisHit;
207 fVolume[volumeIndex].last = (void *)thisHit;
208
209
210 //set row pointers
211 if(fRow[localrow].first == NULL)
212 fRow[localrow].first = (void *)thisHit;
213 else
214 ((AliL3ConfMapPoint *)(fRow[localrow].last))->nextRowHit = thisHit;
215 fRow[localrow].last = (void *)thisHit;
216
217 }
218
e0e14b24 219 if(fClustersUnused>0 && local_counter==0)
220 LOG(AliL3Log::kError,"AliL3ConfMapper::SetPointers","Parameters")
221 <<AliL3Log::kDec<<"No points passed to track finder, hits out of range: "
222 <<fEtaHitsOutOfRange+fPhiHitsOutOfRange<<ENDLOG;
223
108615fc 224}
225
226void AliL3ConfMapper::MainVertexTracking_a()
227{
228 //Tracking with vertex constraint.
229
230 if(!fParamSet)
231 {
232 LOG(AliL3Log::kError,"AliL3ConfMapper::MainVertexTracking","Parameters")<<AliL3Log::kDec<<
233 "Tracking parameters not set!"<<ENDLOG;
234 return;
235 }
236
237
238 SetPointers();
239 SetVertexConstraint(true);
240}
241
242void AliL3ConfMapper::MainVertexTracking_b()
243{
244 //Tracking with vertex constraint.
245
246 if(!fParamSet)
247 {
248 LOG(AliL3Log::kError,"AliL3ConfMapper::MainVertexTracking","Parameters")<<AliL3Log::kDec<<
249 "Tracking parameters not set!"<<ENDLOG;
250 return;
251 }
252
253 ClusterLoop();
254}
255
256void AliL3ConfMapper::MainVertexTracking()
257{
258 //Tracking with vertex constraint.
259
260 if(!fParamSet)
261 {
262 LOG(AliL3Log::kError,"AliL3ConfMapper::MainVertexTracking","Parameters")<<AliL3Log::kDec<<
263 "Tracking parameters not set!"<<ENDLOG;
264 return;
265 }
266
267 Double_t initCpuTime,cpuTime;
268 initCpuTime = CpuTime();
269
270 SetPointers();
271 SetVertexConstraint(true);
272
273 ClusterLoop();
274
275 cpuTime = CpuTime() - initCpuTime;
276 if(fBench)
277 LOG(AliL3Log::kInformational,"AliL3ConfMapper::MainVertexTracking","Timing")<<AliL3Log::kDec<<
278 "Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
279
280 return;
281}
282
283void AliL3ConfMapper::NonVertexTracking()
284{
285 //Tracking with no vertex constraint. This should be called after doing MainVertexTracking,
286 //in order to do tracking on the remaining clusters.
287 //The conformal mapping is now done with respect to the first cluster
288 //assosciated with this track.
289
290 SetVertexConstraint(false);
291 ClusterLoop();
292 LOG(AliL3Log::kInformational,"AliL3ConfMapper::NonVertexTracking","ntracks")<<AliL3Log::kDec<<
293 "Number of nonvertex tracks found: "<<nTracks-fMainVertexTracks<<ENDLOG;
294
295 return;
296}
297
298void AliL3ConfMapper::MainVertexSettings(Int_t trackletlength, Int_t tracklength,
299 Int_t rowscopetracklet, Int_t rowscopetrack,
300 Double_t maxphi,Double_t maxeta)
301{
302 //Settings for main vertex tracking. The cuts are:
303 //TrackletLength: #hits on segment, before trying to build a track
304 //TrackLength: Minimum hits on a track
305 //RowScopeTracklet: Row search range for segments
306 //RowScopeTrack: Row search range for tracks
307
308 SetTrackletLength(trackletlength,(Bool_t)true);
309 SetRowScopeTracklet(rowscopetracklet, (Bool_t) true);
310 SetRowScopeTrack(rowscopetrack, (Bool_t) true);
311 SetMinPoints(tracklength,(Bool_t)true);
312 fMaxPhi=maxphi;
313 fMaxEta=maxeta;
314
315}
316
317void AliL3ConfMapper::NonVertexSettings(Int_t trackletlength, Int_t tracklength,
318 Int_t rowscopetracklet, Int_t rowscopetrack)
319{
320 SetTrackletLength(trackletlength,(Bool_t)false);
321 SetRowScopeTracklet(rowscopetracklet, (Bool_t)false);
322 SetRowScopeTrack(rowscopetrack, (Bool_t)false);
323 SetMinPoints(tracklength,(Bool_t)false);
324}
325
326void AliL3ConfMapper::SetTrackCuts(Double_t hitChi2Cut, Double_t goodHitChi2, Int_t trackChi2Cut,Int_t maxdist)
327{
328 //Settings for tracks. The cuts are:
329 //HitChi2Cut: Maximum hit chi2
330 //goodHitChi2: Chi2 to stop look for next hit
331 //trackChi2Cut: Maximum track chi2
332 //maxdist: Maximum distance between two clusters when forming segments
333
334 fHitChi2Cut = hitChi2Cut;
335 fGoodHitChi2 = goodHitChi2;
336 fTrackChi2Cut = trackChi2Cut;
337 fMaxDist = maxdist;
338}
339
340void AliL3ConfMapper::SetTrackletCuts(Double_t maxangle,Double_t goodDist, Bool_t vertex_constraint)
341{
342 //Sets cuts of tracklets. Right now this is only:
343 //maxangle: Maximum angle when forming segments (if trackletlength > 2)
344
345 fGoodDist=goodDist;
346 SetMaxAngleTracklet(maxangle, vertex_constraint);
347}
348
349void AliL3ConfMapper::ClusterLoop()
350{
351 //Loop over hits, starting at outermost padrow, and trying to build segments.
352
353 Int_t row_segm,lastrow = fRowMin + fMinPoints[fVertexConstraint];
354 AliL3ConfMapPoint *hit;
355
356 //Loop over rows, and try to create tracks from the hits.
357 //Starts at the outermost row, and loops as long as a track can be build, due to length.
358
359 for(row_segm = fRowMax; row_segm >= lastrow; row_segm--)
360 {
361 if(fRow[row_segm].first && ((AliL3ConfMapPoint*)fRow[row_segm].first)->GetPadRow() < fRowMin + 1)
362 break;
363 for(hit = (AliL3ConfMapPoint*)fRow[row_segm].first; hit!=0; hit=hit->nextRowHit)
364 {
365 if(hit->GetUsage() == true)
366 continue;
367 else
368 CreateTrack(hit);
369 }
370 }
371
372 return;
373}
374
375
376void AliL3ConfMapper::CreateTrack(AliL3ConfMapPoint *hit)
377{
378 //Tries to create a track from the initial hit given by ClusterLoop()
379
380 AliL3ConfMapPoint *closest_hit = NULL;
381 AliL3ConfMapTrack *track = NULL;
382
383 Int_t point;
384 Int_t tracks = nTracks;
385 nTracks++;
386
387 track = (AliL3ConfMapTrack*)fTrack->NextTrack();
388
389 //reset hit parameters:
390 track->Reset();
391
392 UInt_t *trackhitnumber = track->GetHitNumbers();
393
394 //set conformal coordinates if we are looking for non vertex tracks
395 if(!fVertexConstraint)
396 {
397 hit->SetAllCoord(hit);
398 }
399
400 //fill fit parameters of initial track:
401 track->UpdateParam(hit); //here the number of hits is incremented.
402 trackhitnumber[track->GetNumberOfPoints()-1] = hit->GetHitNumber();
403
404 Double_t dx,dy;
405 //create tracklets:
406
407 for(point=1; point<fTrackletLength[fVertexConstraint]; point++)
408 {
409 if((closest_hit = GetNextNeighbor(hit)))
410 {//closest hit exist
411
412 // Calculate track length in sz plane
413 dx = ((AliL3ConfMapPoint*)closest_hit)->GetX() - ((AliL3ConfMapPoint*)hit)->GetX();
414 dy = ((AliL3ConfMapPoint*)closest_hit)->GetY() - ((AliL3ConfMapPoint*)hit)->GetY();
415 //track->fLength += (Double_t)sqrt ( dx * dx + dy * dy ) ;
416 Double_t length = track->GetLength()+(Double_t)sqrt ( dx * dx + dy * dy );
417 track->SetLength(length);
418
419 //closest_hit->SetS(track->fLength);
420 closest_hit->SetS(track->GetLength());
421
422 //update fit parameters
423 track->UpdateParam(closest_hit);
424 trackhitnumber[track->GetNumberOfPoints()-1] = closest_hit->GetHitNumber();
425
426 hit = closest_hit;
427 }
428 else
429 {
430 //closest hit does not exist:
431 track->DeleteCandidate();
432 fTrack->RemoveLast();
433 nTracks--;
434 point = fTrackletLength[fVertexConstraint];
435 }
436 }
437
438 //tracklet is long enough to be extended to a track
439 if(track->GetNumberOfPoints() == fTrackletLength[fVertexConstraint])
440 {
441
442 track->SetProperties(true);
443
444 if(TrackletAngle(track) > fMaxAngleTracklet[fVertexConstraint])
445 {//proof if the first points seem to be a beginning of a track
446
447 track->SetProperties(false);
448 track->DeleteCandidate();
449 fTrack->RemoveLast();
450 nTracks--;
451 }
452
453 else//good tracklet ->proceed, follow the trackfit
454 {
455 tracks++;
456
457 //define variables to keep the total chi:
458 Double_t xyChi2 = track->fChiSq[0];
459 Double_t szChi2 = track->fChiSq[1];
460
461 for(point = fTrackletLength[fVertexConstraint]; point <= fNumRowSegment; point++)
462 {
463 track->fChiSq[0] = fHitChi2Cut;
464 closest_hit = GetNextNeighbor((AliL3ConfMapPoint*)track->lastHit,track);
465
466 if(closest_hit)
467 {
468
469 //keep total chi:
470 Double_t lxyChi2 = track->fChiSq[0]-track->fChiSq[1];
471 xyChi2 += lxyChi2;
472 closest_hit->xyChi2 = lxyChi2;
473
474 //update track length:
475 //track->fLength = closest_hit->GetS();
476 track->SetLength(closest_hit->GetS());
477 szChi2 += track->fChiSq[1];
478 closest_hit->szChi2 = track->fChiSq[1];
479
480 track->UpdateParam(closest_hit);
481 trackhitnumber[track->GetNumberOfPoints()-1] = closest_hit->GetHitNumber();
482
483 //add closest hit to track
484 closest_hit->SetUsage(true);
485 closest_hit->SetTrackNumber(tracks-1);
486
487 }//closest_hit
488
489 else
490 {
491 //closest hit does not exist
492 point = fNumRowSegment; //continue with next hit in segment
493 }//else
494
495 }//create tracks
496
497 //store track chi2:
498 track->fChiSq[0] = xyChi2;
499 track->fChiSq[1] = szChi2;
500 Double_t normalized_chi2 = (track->fChiSq[0]+track->fChiSq[1])/track->GetNumberOfPoints();
501
502 //remove tracks with not enough points already now
503 if(track->GetNumberOfPoints() < fMinPoints[fVertexConstraint] || normalized_chi2 > fTrackChi2Cut)
504 {
505 track->SetProperties(false);
506 nTracks--;
507 track->DeleteCandidate();
508 fTrack->RemoveLast();
509 tracks--;
510 }
511
512 else
513 {
514 fClustersUnused -= track->GetNumberOfPoints();
515 track->ComesFromMainVertex(fVertexConstraint);
516 //mark track as main vertex track or not
517 track->SetSector(2); //only needed for testing purposes.
518 track->SetRowRange(fRowMin,fRowMax);
519
520 if(fVertexConstraint)
521 fMainVertexTracks++;
522 }
523
524 }//good tracklet
525
526 }
527
528 return;
529}
530
531AliL3ConfMapPoint *AliL3ConfMapper::GetNextNeighbor(AliL3ConfMapPoint *start_hit,
532 AliL3ConfMapTrack *track)
533{
534 //When forming segments: Finds closest hit to input hit
535 //When forming tracks: Find closest hit to track fit.
536
537 Double_t dist,closest_dist = fMaxDist;
538
539 AliL3ConfMapPoint *hit = NULL;
540 AliL3ConfMapPoint *closest_hit = NULL;
541
542 Int_t sub_row_segm;
543 Int_t sub_phi_segm;
544 Int_t sub_eta_segm;
545 Int_t volumeIndex;
546 Int_t test_hit;
547
548 Int_t max_row = start_hit->GetPadRow()-1;
549 Int_t min_row;
550
551 if(track) //finding hit close to trackfit
552 {
553 min_row = start_hit->GetPadRow()-fRowScopeTrack[fVertexConstraint];
554 }
555 else
556 {
557 min_row = start_hit->GetPadRow()-fRowScopeTracklet[fVertexConstraint];
558 }
559
560 //make a smart loop
561 Int_t loop_eta[9] = {0,0,0,-1,-1,-1,1,1,1};
562 Int_t loop_phi[9] = {0,-1,1,0,-1,1,0,-1,1};
563
564 if(min_row < fRowMin)
565 min_row = fRowMin;
566 if(max_row < fRowMin)
567 return 0; //reached the last padrow under consideration
568
569 else
570 {
571 //loop over sub rows
572 for(sub_row_segm=max_row; sub_row_segm>=min_row; sub_row_segm--)
573 {
574 //loop over subsegments, in the order defined above.
575 for(Int_t i=0; i<9; i++)
576 {
577 sub_phi_segm = start_hit->phiIndex + loop_phi[i];
578
579 if(sub_phi_segm<0)
580 sub_phi_segm += fNumPhiSegment;
581
582 else if(sub_phi_segm >=fNumPhiSegment)
583 sub_phi_segm -= fNumPhiSegment;
584
585 //loop over sub eta segments
586
587 sub_eta_segm = start_hit->etaIndex + loop_eta[i];
588
589 if(sub_eta_segm < 0 || sub_eta_segm >=fNumEtaSegment)
590 continue;//segment exceeds bounds->skip it
591
592 //loop over hits in this sub segment:
593 volumeIndex= sub_row_segm*fNumPhiEtaSegmentPlusOne +
594 sub_phi_segm*fNumEtaSegmentPlusOne + sub_eta_segm;
595
596 if(volumeIndex<0)
597 {//debugging
598 LOG(AliL3Log::kError,"AliL3ConfMapper::GetNextNeighbor","Memory")<<AliL3Log::kDec<<
599 "VolumeIndex error "<<volumeIndex<<ENDLOG;
600 }
601
602 for(hit = (AliL3ConfMapPoint*)fVolume[volumeIndex].first;
603 hit!=0; hit = hit->nextVolumeHit)
604 {
605
606 if(!hit->GetUsage())
607 {//hit was not used before
608
609 //set conformal mapping if looking for nonvertex tracks:
610 if(!fVertexConstraint)
611 {
612 hit->SetAllCoord(start_hit);
613 }
614
615 if(track)//track search - look for nearest neighbor to extrapolated track
616 {
617 if(!VerifyRange(start_hit,hit))
618 continue;
619
620 test_hit = EvaluateHit(start_hit,hit,track);
621
622 if(test_hit == 0)//chi2 not good enough, keep looking
623 continue;
624 else if(test_hit==2)//chi2 good enough, return it
625 return hit;
626 else
627 closest_hit = hit;//chi2 acceptable, but keep looking
628
629 }//track search
630
631 else //tracklet search, look for nearest neighbor
632 {
633
634 if((dist=CalcDistance(start_hit,hit)) < closest_dist)
635 {
636 if(!VerifyRange(start_hit,hit))
637 continue;
638 closest_dist = dist;
639 closest_hit = hit;
640
641 //if this hit is good enough, return it:
642 if(closest_dist < fGoodDist)
643 return closest_hit;
644 }
645 else
646 continue;//sub hit was farther away than a hit before
647
648 }//tracklet search
649
650 }//hit not used before
651
652 else continue; //sub hit was used before
653
654 }//loop over hits in sub segment
655
656 }//loop over sub segments
657
658 }//loop over subrows
659
660 }//else
661
662 //closest hit found:
663 if(closest_hit)// && closest_dist < mMaxDist)
664 return closest_hit;
665 else
666 return 0;
667}
668
669Int_t AliL3ConfMapper::EvaluateHit(AliL3ConfMapPoint *start_hit,AliL3ConfMapPoint *hit,AliL3ConfMapTrack *track)
670{
671 //Check if space point gives a fit with acceptable chi2.
672
673 Double_t temp,dxy,lchi2,dx,dy,slocal,dsz,lszChi2;
674 temp = (track->a2Xy*hit->GetXprime()-hit->GetYprime()+track->a1Xy);
675 dxy = temp*temp/(track->a2Xy*track->a2Xy + 1.);
676
677 //Calculate chi2
678 lchi2 = (dxy*hit->GetXYWeight());
679
680 if(lchi2 > track->fChiSq[0])//chi2 was worse than before.
681 return 0;
682
683 //calculate s and the distance hit-line
684 dx = start_hit->GetX()-hit->GetX();
685 dy = start_hit->GetY()-hit->GetY();
686 //slocal = track->fLength+sqrt(dx*dx+dy*dy);
687 slocal = track->GetLength()+sqrt(dx*dx+dy*dy);
688
689 temp = (track->a2Sz*slocal-hit->GetZ()+track->a1Sz);
690 dsz = temp*temp/(track->a2Sz*track->a2Sz+1);
691
692 //calculate chi2
693 lszChi2 = dsz*hit->GetZWeight();
694 lchi2 += lszChi2;
695
696
697 //check whether chi2 is better than previous one:
698 if(lchi2 < track->fChiSq[0])
699 {
700 track->fChiSq[0] = lchi2;
701 track->fChiSq[1] = lszChi2;
702
703 hit->SetS(slocal);
704
705 //if chi2 good enough, stop here:
706 if(lchi2 < fGoodHitChi2)
707 return 2;
708
709 return 1;
710 }
711
712 return 0;
713
714}
715
716Double_t AliL3ConfMapper::CalcDistance(const AliL3ConfMapPoint *hit1,const AliL3ConfMapPoint *hit2) const
717{
718 //Return distance between two clusters, defined by Pablo
719
720 Double_t phi_diff = fabs( hit1->GetPhi() - hit2->GetPhi() );
721 if (phi_diff > pi) phi_diff = twopi - phi_diff;
722
723 return todeg*fabs(hit1->GetPadRow() - hit2->GetPadRow()) * (phi_diff + fabs( hit1->GetEta() - hit2->GetEta() ));
724}
725
726Bool_t AliL3ConfMapper::VerifyRange(const AliL3ConfMapPoint *hit1,const AliL3ConfMapPoint *hit2) const
727{
728 //Check if the hit are within reasonable range in phi and eta
729 Double_t dphi,deta;//maxphi=0.1,maxeta=0.1;
730 dphi = fabs(hit1->GetPhi() - hit2->GetPhi());
731 if(dphi > pi) dphi = fabs(twopi - dphi);
732 if(dphi > fMaxPhi) return false;
733
734 deta = fabs(hit1->GetEta() - hit2->GetEta());
735 if(deta > fMaxEta) return false;
736
737 return true;
738
739}
740
741Double_t AliL3ConfMapper::TrackletAngle(const AliL3ConfMapTrack *track,Int_t n) const
742{
743 // Returns the angle 'between' the last three points (started at point number n) on this track.
744
745 return 0;
746 /*
747 Double_t x1[2];
748 Double_t x2[2];
749 Double_t angle1,angle2;
750 TObjArray *hits = track->GetHits();
751
752 if (n > track->GetNumberOfPoints()) {
753 n = track->GetNumberOfPoints();
754 }
755
756 if (n<3)
757 return 0;
758
759
760 x1[0] = ((AliL3ConfMapPoint *)hits->At(n-2))->GetX() - ((AliL3ConfMapPoint *)hits->At(n-3))->GetX();
761 x1[1] = ((AliL3ConfMapPoint *)hits->At(n-2))->GetY() - ((AliL3ConfMapPoint *)hits->At(n-3))->GetY();
762
763 x2[0] = ((AliL3ConfMapPoint *)hits->At(n-1))->GetX() - ((AliL3ConfMapPoint *)hits->At(n-2))->GetX();
764 x2[1] = ((AliL3ConfMapPoint *)hits->At(n-1))->GetY() - ((AliL3ConfMapPoint *)hits->At(n-2))->GetY();
765
766 angle1 = atan2(x1[1],x1[0]);
767 angle2 = atan2(x2[1],x1[0]);
768 return fabs(angle1-angle2);
769 */
770}
771
772Int_t AliL3ConfMapper::FillTracks()
773{
774 //Fill track parameters. Which basically means do a fit of helix in real space,
775 //which should be done in order to get nice tracks.
776
777 Int_t num_of_tracks = nTracks;
778 LOG(AliL3Log::kInformational,"AliL3ConfMapper::FillTracks","nTracks")<<AliL3Log::kDec<<
779 "Number of found tracks: "<<nTracks<<ENDLOG;
780
781 if(nTracks == 0)
782 {
783 LOG(AliL3Log::kError,"AliL3ConfMapper::FillTracks","nTracks")<<AliL3Log::kDec<<
784 "No tracks found!!"<<ENDLOG;
785 return 0;
786 }
787
788 // fTrack->Sort();
789 for(int i=0; i<num_of_tracks; i++)
790 {
791 AliL3ConfMapTrack *track = (AliL3ConfMapTrack*)fTrack->GetTrack(i);
792 track->Fill(fVertex,fMaxDca);
793 }
794 return 1;
795
796}
797
798Double_t AliL3ConfMapper::CpuTime()
799{
800 //Return the Cputime in seconds.
801
802 return (Double_t)(clock()) / CLOCKS_PER_SEC;
803}