]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/hough/AliL3HoughTransformerLUT.h
Worked over Makefiles for standalone HLT version, no changes when you compile with...
[u/mrichter/AliRoot.git] / HLT / hough / AliL3HoughTransformerLUT.h
1 // @(#) $Id$
2
3 #ifndef ALIL3_HOUGHTRANSFORMERLUT
4 #define ALIL3_HOUGHTRANSFORMERLUT
5
6 #include "AliL3RootTypes.h"
7 #include "AliL3HoughBaseTransformer.h"
8 #include "AliL3Histogram.h"
9
10 /* use if you also want the eta index 
11    to be looked up and linear searched */
12 //#define FULLLUT
13
14 class AliL3HoughTransformerLUT : public AliL3HoughBaseTransformer {
15   
16  public:
17
18   AliL3HoughTransformerLUT(); 
19   AliL3HoughTransformerLUT(Int_t slice,Int_t patch,Int_t nEtaSegments);
20   virtual ~AliL3HoughTransformerLUT();
21   
22   void CreateHistograms(Float_t ptmin,Float_t ptmax,Float_t pres,Int_t nybin,Float_t psi);
23   void CreateHistograms(Int_t nxbin,Float_t ptmin,Int_t nybin,Float_t phimin,Float_t phimax);
24   void CreateHistograms(Int_t nxbin,Float_t xmin,Float_t xmax,Int_t nybin,Float_t ymin,Float_t ymax);
25   void Reset();
26
27   void TransformCircle();
28
29   Int_t GetEtaIndex(Double_t eta) const;
30   AliL3Histogram *GetHistogram(Int_t etaIndex);
31   Double_t GetEta(Int_t etaIndex,Int_t slice) const;
32   
33   void Print();
34   void Init(Int_t slice=0,Int_t patch=0,Int_t nEtaSegments=100,Int_t nSeqs=-1);
35
36  protected:
37   AliL3Histogram **fParamSpace; //!
38
39   void DeleteHistograms();
40   
41   Int_t fMinRow; // Min row (= first row)
42   Int_t fMaxRow; // Max row (= last row)
43   Int_t fNRows;  // Number of rows
44   Int_t fNEtas;  // Number of eta slices
45   Int_t fNPhi0;  // Number of phi bins
46   Int_t fSlice;  // Current slice
47   Int_t fSector; // Current sector
48   Int_t fSectorRow; // Sector row (?)
49   Int_t fZSign; // Z sign
50   Float_t fZLengthPlusOff; // Z lenght plus offset
51   Float_t fTimeWidth; // Time width
52   Float_t fPadPitch; // Pad pitch
53   Float_t fEtaSlice; // Eta slice
54
55   Float_t *fLUTX; //! LUT for X
56   Float_t *fLUTY; //! LUT for Y
57   Float_t *fLUTEta; //! LUT for eta
58   Float_t *fLUTEtaReal; //! LUT for real eta (?)
59   Float_t *fLUTphi0; //! LUT for phi0
60   Float_t *fLUT2sinphi0; //! LUT for sin(phi0)
61   Float_t *fLUT2cosphi0; //! LUT for cos(phi0)
62   //not used but need for VHDL version
63   Float_t *fLUTKappa; //! LUT for kappa
64   
65   Int_t fLastPad; // Last pad
66   Int_t fLastIndex; // Last index
67   Int_t fAccCharge; // Accepted charge
68   Float_t fX,fY; //trafo values per pad
69
70   Float_t CalcRoverZ2(Float_t eta) const;
71   Float_t CalcEta(Float_t roverz2) const;
72   Float_t CalcX(Int_t row) const;
73   Float_t CalcY(Int_t pad, Int_t row) const;
74   Float_t CalcZ(Int_t time) const;  
75   Int_t FindIndex(Float_t rz2, Int_t start=-100) const;
76   void AddCurveToHistogram(Int_t newEtaIndex=-1);
77
78   ClassDef(AliL3HoughTransformerLUT,1) //LUT Hough transformation class
79
80 };
81
82 inline Float_t AliL3HoughTransformerLUT::CalcRoverZ2(Float_t eta) const
83 {
84   Float_t e=exp(2*eta);
85   Float_t ret=(e+1)/(e-1);
86   ret*=ret;
87   return ret;
88 }
89
90 inline Float_t AliL3HoughTransformerLUT::CalcEta(Float_t roverz2) const
91 {
92   Float_t rz=sqrt(roverz2);
93   if(fZSign<0) rz=-rz;
94   Float_t ret=(1+rz)/(rz-1);
95   ret=0.5*log(ret);
96   return ret;
97 }
98
99 inline Float_t AliL3HoughTransformerLUT::CalcX(Int_t row) const
100 {
101   return fLUTX[row];
102 }
103
104 inline Float_t AliL3HoughTransformerLUT::CalcY(Int_t pad,Int_t row) const
105 {
106   return pad*fPadPitch-fLUTY[row];
107 }
108
109 inline Float_t AliL3HoughTransformerLUT::CalcZ(Int_t time) const
110 {
111   Float_t ret=time*fTimeWidth;
112   if(fZSign>0) ret=fZLengthPlusOff-ret;
113   else ret=ret-fZLengthPlusOff;
114   return ret;
115 }
116
117 inline void AliL3HoughTransformerLUT::AddCurveToHistogram(Int_t newEtaIndex)
118 {
119   //get correct histogrampointer
120   AliL3Histogram *hist = fParamSpace[fLastIndex];
121
122   //Fill the histogram along the phirange
123   Float_t r2=fX*fX+fY*fY;
124   for(Int_t b=0; b<fNPhi0; b++){
125     Float_t kappa=(fY*fLUT2cosphi0[b]-fX*fLUT2sinphi0[b])/r2;
126     hist->Fill(kappa,b+1,fAccCharge);
127     //cout << kappa << " " << fLUTphi0[b] << " " << fAccCharge << endl;
128   }
129
130   fAccCharge=0;
131   fLastIndex=newEtaIndex;
132 }
133
134 inline Int_t AliL3HoughTransformerLUT::FindIndex(Float_t rz2, Int_t start) const
135 {
136   //could improve search through devide and conquere strategy
137   
138   Int_t index=start; 
139   if(index==-100){
140     index=0;
141     while((index<fNEtas)&&(rz2<=fLUTEta[index])){
142       index++;
143     }
144   } else {
145     while((index>=0)&&(rz2>fLUTEta[index])){
146       index--;
147     }
148     index++;
149   }
150   //cout << start << " - " << index << " " << ": " << rz2 << " " << fLUTEta[index] << endl;
151
152   return index;
153 }
154
155
156
157
158 #endif