8cdbbc81e35c0b13540f5de64b42edf44a723f9b
[u/mrichter/AliRoot.git] / HLT / hough / AliL3HoughMaxFinder.h
1 #ifndef ALIL3_HOUGH_MaxFinder
2 #define ALIL3_HOUGH_MaxFinder
3
4 #include "AliL3RootTypes.h"
5 #include <stream.h>
6
7 class AliL3Histogram;
8 class AliL3TrackArray;
9 class AliL3HoughTrack;
10 class TNtuple;
11
12 struct AxisWindow
13 {
14   Int_t ymin;
15   Int_t ymax;
16   Int_t xbin;
17   Int_t weight;
18 };
19
20 class AliL3HoughMaxFinder {
21   
22  private:
23
24   Int_t fThreshold;
25   AliL3Histogram *fCurrentHisto;  //!
26   
27   Float_t *fXPeaks; //!
28   Float_t *fYPeaks; //!
29   Int_t *fWeight;   //!
30   Int_t fNPeaks;
31   Int_t fNMax;
32   
33   Char_t fHistoType;
34
35 #ifndef no_root
36   TNtuple *fNtuppel; //!
37 #endif
38
39  public:
40   AliL3HoughMaxFinder(); 
41   AliL3HoughMaxFinder(Char_t *histotype,Int_t nmax,AliL3Histogram *hist=0);
42   virtual ~AliL3HoughMaxFinder();
43   void Reset();
44
45   void CreateNtuppel();
46   void WriteNtuppel(Char_t *filename);
47
48   //Simple maxima finders:
49   void FindAbsMaxima();
50   void FindBigMaxima();
51   void FindMaxima(Double_t grad_x,Double_t grad_y);
52   
53   //More sophisticated peak finders:
54   AliL3TrackArray *LookForPeaks(AliL3Histogram *hist,Int_t nbins);
55   void FindPeak(Int_t t1,Double_t t2,Int_t t3);
56   AliL3HoughTrack *FindPeakLine(Double_t rho,Double_t theta);
57   AliL3HoughTrack *CalculatePeakInWindow(Int_t *maxbin,Int_t t0,Int_t t1,Double_t t2,Int_t t3);
58   void FindPeak1(Int_t y_window=2,Int_t x_bin_sides=1);
59   void SortPeaks(struct AxisWindow **a,Int_t first,Int_t last);
60   Int_t PeakCompare(struct AxisWindow *a,struct AxisWindow *b);
61   
62   //Setters:
63   void SetThreshold(Int_t f) {fThreshold = f;}
64   void SetHistogram(AliL3Histogram *hist) {fCurrentHisto = hist;}
65   
66   //Getters:
67   Float_t GetXPeak(Int_t i);
68   Float_t GetYPeak(Int_t i);
69   Int_t GetWeight(Int_t i);
70   Int_t GetEntries() {return fNPeaks;}
71
72   ClassDef(AliL3HoughMaxFinder,1) //Maximum finder class
73
74 };
75
76 inline Float_t AliL3HoughMaxFinder::GetXPeak(Int_t i)
77 {
78   if(i<0 || i>fNMax)
79     {
80       cerr<<"AliL3HoughMaxFinder::GetXPeak : Invalid index "<<i<<endl;
81       return 0;
82     }
83   return fXPeaks[i];
84 }
85
86 inline Float_t AliL3HoughMaxFinder::GetYPeak(Int_t i)
87 {
88   if(i<0 || i>fNMax)
89     {
90       cerr<<"AliL3HoughMaxFinder::GetYPeak : Invalid index "<<i<<endl;
91       return 0;
92     }
93   return fYPeaks[i];
94
95 }
96
97 inline Int_t AliL3HoughMaxFinder::GetWeight(Int_t i)
98 {
99   if(i<0 || i>fNMax)
100     {
101       cerr<<"AliL3HoughMaxFinder::GetWeight : Invalid index "<<i<<endl;
102       return 0;
103     }
104   return fWeight[i];
105 }
106
107 #endif
108