Added Cylinderical Coordinates for use with Tracking. Fixed a but in the
[u/mrichter/AliRoot.git] / HLT / hough / AliL3HoughMaxFinder.cxx
CommitLineData
4de874d1 1#include <string.h>
2
3#include <TH2.h>
4
5#include "AliL3TrackArray.h"
6#include "AliL3HoughTrack.h"
7#include "AliL3HoughMaxFinder.h"
8
9ClassImp(AliL3HoughMaxFinder)
10
11
12AliL3HoughMaxFinder::AliL3HoughMaxFinder()
13{
14 //Default constructor
15 fThreshold = 0;
16 //fTracks = 0;
17 fHistoType=0;
18}
19
20
21AliL3HoughMaxFinder::AliL3HoughMaxFinder(Char_t *histotype)
22{
23 //Constructor
24
25 //fTracks = new AliL3TrackArray("AliL3HoughTrack");
26 if(strcmp(histotype,"KappaPhi")==0) fHistoType='c';
27 if(strcmp(histotype,"DPsi")==0) fHistoType='l';
28
29}
30
31
32AliL3HoughMaxFinder::~AliL3HoughMaxFinder()
33{
34 //Destructor
35
36}
37
38
39AliL3TrackArray *AliL3HoughMaxFinder::FindMaxima(TH2F *hist,Int_t *rowrange,Int_t ref_row)
40{
41 //Locate all the maxima in input histogram.
42 //Maxima is defined as bins with more entries than the
43 //immediately neighbouring bins.
44
45 Int_t xmin = hist->GetXaxis()->GetFirst();
46 Int_t xmax = hist->GetXaxis()->GetLast();
47 Int_t ymin = hist->GetYaxis()->GetFirst();
48 Int_t ymax = hist->GetYaxis()->GetLast();
49 Int_t bin[9],track_counter=0;
50 Stat_t value[9];
51
52 AliL3TrackArray *tracks = new AliL3TrackArray("AliL3HoughTrack");
53 AliL3HoughTrack *track;
54
55 for(Int_t xbin=xmin+1; xbin<xmax-1; xbin++)
56 {
57 for(Int_t ybin=ymin+1; ybin<ymax-1; ybin++)
58 {
59 bin[0] = hist->GetBin(xbin-1,ybin-1);
60 bin[1] = hist->GetBin(xbin,ybin-1);
61 bin[2] = hist->GetBin(xbin+1,ybin-1);
62 bin[3] = hist->GetBin(xbin-1,ybin);
63 bin[4] = hist->GetBin(xbin,ybin);
64 bin[5] = hist->GetBin(xbin+1,ybin);
65 bin[6] = hist->GetBin(xbin-1,ybin+1);
66 bin[7] = hist->GetBin(xbin,ybin+1);
67 bin[8] = hist->GetBin(xbin+1,ybin+1);
68 value[0] = hist->GetBinContent(bin[0]);
69 value[1] = hist->GetBinContent(bin[1]);
70 value[2] = hist->GetBinContent(bin[2]);
71 value[3] = hist->GetBinContent(bin[3]);
72 value[4] = hist->GetBinContent(bin[4]);
73 value[5] = hist->GetBinContent(bin[5]);
74 value[6] = hist->GetBinContent(bin[6]);
75 value[7] = hist->GetBinContent(bin[7]);
76 value[8] = hist->GetBinContent(bin[8]);
77
78 if(value[4] <= fThreshold) continue;//central bin below threshold
79
80 if(value[4]>value[0] && value[4]>value[1] && value[4]>value[2]
81 && value[4]>value[3] && value[4]>value[5] && value[4]>value[6]
82 && value[4]>value[7] && value[4]>value[8])
83 {
84 //Found a local maxima
85 Float_t max_x = hist->GetXaxis()->GetBinCenter(xbin);
86 Float_t max_y = hist->GetYaxis()->GetBinCenter(ybin);
87
88 track = (AliL3HoughTrack*)tracks->NextTrack();
89
90
91 switch(fHistoType)
92 {
93 case 'c':
94 track->SetTrackParameters(max_x,max_y,(Int_t)value[4]);
95 break;
96 case 'l':
97 track->SetLineParameters(max_x,max_y,(Int_t)value[4],rowrange,ref_row);
98 break;
99 default:
100 printf("AliL3HoughMaxFinder: Error in tracktype\n");
101 }
102
103 track_counter++;
104
105
106 }
107 else
108 continue; //not a maxima
109 }
110 }
111 tracks->QSort();
112 return tracks;
113}