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