]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/hough/AliHLTHoughMaxFinder.h
New version of SPD raw-data reconstruction. The format now correponds to the actual...
[u/mrichter/AliRoot.git] / HLT / hough / AliHLTHoughMaxFinder.h
1 // @(#) $Id$
2
3 #ifndef ALIL3HOUGHMAXFINDER_H
4 #define ALIL3HOUGHMAXFINDER_H
5
6 #include "AliHLTRootTypes.h"
7 #include "AliHLTStandardIncludes.h"
8
9 class AliHLTHistogram;
10 class AliHLTTrackArray;
11 class AliHLTHoughTrack;
12 class TNtuple;
13
14 struct AliHLTAxisWindow
15 {
16   Int_t fYmin; // min Y
17   Int_t fYmax; // max Y
18   Int_t fXbin; // X bin
19   Int_t fWeight; // weight
20 };
21
22 struct AliHLTPre2DPeak
23 {
24   Float_t fX; // X coordinate of the preak
25   Float_t fY; // Y coordinate of the preak
26   Float_t fSizeX; // Size of the peak
27   Float_t fSizeY; // Size of the peak
28   Int_t fStartX; // Start position of the peak
29   Int_t fStartY; // Start position of the peak
30   Int_t fEndX; // End position of the peak
31   Int_t fEndY; // End position of the peak
32   Float_t fWeight; // Weight assigned to the peak
33 };
34
35 class AliHLTHoughMaxFinder {
36
37  public:
38   AliHLTHoughMaxFinder(); 
39   AliHLTHoughMaxFinder(Char_t *histotype,Int_t nmax,AliHLTHistogram *hist=0);
40   virtual ~AliHLTHoughMaxFinder();
41   void Reset();
42
43   void CreateNtuppel();
44   void WriteNtuppel(Char_t *filename);
45
46   //Simple maxima finders:
47   void FindAbsMaxima();
48   void FindBigMaxima();
49   void FindMaxima(Int_t threshold=0);
50   void FindAdaptedPeaks(Int_t nkappawindow,Float_t cutratio);
51   //Peak finder for HoughTransformerRow
52   void FindAdaptedRowPeaks(Int_t kappawindow,Int_t xsize,Int_t ysize);
53   //More sophisticated peak finders:
54   void FindPeak(Int_t t1,Double_t t2,Int_t t3);
55   void FindPeak1(Int_t ywindow=2,Int_t xbinsides=1);
56   void SortPeaks(struct AliHLTAxisWindow **a,Int_t first,Int_t last);
57   Int_t PeakCompare(struct AliHLTAxisWindow *a,struct AliHLTAxisWindow *b) const;
58   
59   //Setters:
60   void SetGradient(Float_t x,Float_t y) {fGradX=x; fGradY=y;}
61   void SetThreshold(Int_t f) {fThreshold = f;}
62   void SetHistogram(AliHLTHistogram *hist) {fCurrentHisto = hist;}
63   void SetTrackLUTs(UChar_t *tracknrows, UChar_t *trackfirstrow, UChar_t *tracklastrow, UChar_t *nextrow) {fTrackNRows = tracknrows; fTrackFirstRow = trackfirstrow; fTrackLastRow = tracklastrow; fNextRow = nextrow;}
64   void SetEtaSlice(Int_t etaslice) {fCurrentEtaSlice = etaslice;}
65   
66   //Getters:
67   Float_t GetXPeak(Int_t i) const;
68   Float_t GetYPeak(Int_t i) const;
69   Float_t GetXPeakSize(Int_t i) const;
70   Float_t GetYPeakSize(Int_t i) const;
71   Int_t GetWeight(Int_t i) const;
72   Int_t GetStartEta(Int_t i) const;
73   Int_t GetEndEta(Int_t i) const;
74   Int_t GetEntries() const {return fNPeaks;}
75
76   //Method for merging of peaks produced by AliHLTHoughTransfromerRow
77   Bool_t MergeRowPeaks(AliHLTPre2DPeak *maxima1, AliHLTPre2DPeak *maxima2,Float_t distance);
78   
79  private:
80
81   Int_t fThreshold; // Threshold for Peak Finder
82   Int_t fCurrentEtaSlice; // Current eta slice being processed
83   AliHLTHistogram *fCurrentHisto;  //!
84
85   UChar_t *fTrackNRows; //!
86   UChar_t *fTrackFirstRow; //!
87   UChar_t *fTrackLastRow; //!
88   UChar_t *fNextRow; //!
89   
90   Float_t fGradX; // Gradient threshold inside Peak Finder 
91   Float_t fGradY; // Gradient threshold inside Peak Finder 
92   Float_t *fXPeaks; //!
93   Float_t *fYPeaks; //!
94   Int_t *fSTARTXPeaks; //!
95   Int_t *fSTARTYPeaks; //!
96   Int_t *fENDXPeaks; //!
97   Int_t *fENDYPeaks; //!
98   Int_t *fSTARTETAPeaks; //!
99   Int_t *fENDETAPeaks; //!
100   Int_t *fWeight;   //!
101   Int_t fN1PeaksPrevEtaSlice; // Index of the first peak in the previous eta slice
102   Int_t fN2PeaksPrevEtaSlice; // Index of the  last peak in the previous eta slice
103   Int_t fNPeaks; // Index of the last accumulated peak
104   Int_t fNMax; // Maximum allowed number of peaks
105   
106   Char_t fHistoType; // Histogram type
107
108 #ifndef no_root
109   TNtuple *fNtuppel; //!
110 #endif
111
112   ClassDef(AliHLTHoughMaxFinder,1) //Maximum finder class
113
114 };
115
116 typedef AliHLTHoughMaxFinder AliL3HoughMaxFinder; // for backward compatibility
117
118 inline Float_t AliHLTHoughMaxFinder::GetXPeak(Int_t i) const
119 {
120   if(i<0 || i>fNMax)
121     {
122       STDCERR<<"AliHLTHoughMaxFinder::GetXPeak : Invalid index "<<i<<STDENDL;
123       return 0;
124     }
125   return fXPeaks[i];
126 }
127
128 inline Float_t AliHLTHoughMaxFinder::GetYPeak(Int_t i) const
129 {
130   if(i<0 || i>fNMax)
131     {
132       STDCERR<<"AliHLTHoughMaxFinder::GetYPeak : Invalid index "<<i<<STDENDL;
133       return 0;
134     }
135   return fYPeaks[i];
136
137 }
138
139 inline Int_t AliHLTHoughMaxFinder::GetWeight(Int_t i) const
140 {
141   if(i<0 || i>fNMax)
142     {
143       STDCERR<<"AliHLTHoughMaxFinder::GetWeight : Invalid index "<<i<<STDENDL;
144       return 0;
145     }
146   return fWeight[i];
147 }
148
149 inline Int_t AliHLTHoughMaxFinder::GetStartEta(Int_t i) const
150 {
151   if(i<0 || i>fNMax)
152     {
153       STDCERR<<"AliHLTHoughMaxFinder::GetStartEta : Invalid index "<<i<<STDENDL;
154       return 0;
155     }
156   return fSTARTETAPeaks[i];
157 }
158
159 inline Int_t AliHLTHoughMaxFinder::GetEndEta(Int_t i) const
160 {
161   if(i<0 || i>fNMax)
162     {
163       STDCERR<<"AliHLTHoughMaxFinder::GetStartEta : Invalid index "<<i<<STDENDL;
164       return 0;
165     }
166   return fENDETAPeaks[i];
167 }
168
169 #endif
170