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