]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/hough/AliL3HoughTransformer.cxx
Moved AliL3HoughTrack to hough
[u/mrichter/AliRoot.git] / HLT / hough / AliL3HoughTransformer.cxx
CommitLineData
4cafa5fc 1//Author: Anders Strand Vestbo
99e7186b 2//Last Modified: 14.09.01
4cafa5fc 3
48f3c46f 4#include "AliL3MemHandler.h"
e26acabd 5#include "AliL3Logging.h"
99e7186b 6#include "AliL3HoughTransformer.h"
4de874d1 7#include "AliL3Defs.h"
8#include "AliL3Transform.h"
4cafa5fc 9#include "AliL3DigitData.h"
99e7186b 10#include "AliL3Histogram.h"
4de874d1 11
12ClassImp(AliL3HoughTransformer)
13
14AliL3HoughTransformer::AliL3HoughTransformer()
15{
16 //Default constructor
4cafa5fc 17
4de874d1 18}
19
99e7186b 20AliL3HoughTransformer::AliL3HoughTransformer(Int_t slice,Int_t patch,Int_t n_eta_segments)
52a2a604 21{
52a2a604 22 fSlice = slice;
23 fPatch = patch;
99e7186b 24 fNEtaSegments = n_eta_segments;
25 fEtaMin = 0;
26 fEtaMax = fSlice < 18 ? 0.9 : -0.9;
27 fTransform = new AliL3Transform();
28 fThreshold = 0;
48f3c46f 29 fNDigitRowData=0;
30 fDigitRowData=0;
52a2a604 31}
32
4de874d1 33AliL3HoughTransformer::~AliL3HoughTransformer()
34{
4de874d1 35 if(fTransform)
36 delete fTransform;
99e7186b 37 DeleteHistograms();
4cafa5fc 38}
39
99e7186b 40void AliL3HoughTransformer::DeleteHistograms()
4cafa5fc 41{
99e7186b 42 if(!fParamSpace)
43 return;
44 for(Int_t i=0; i<fNEtaSegments; i++)
4fc9a6a4 45 {
46 if(!fParamSpace[i]) continue;
47 delete fParamSpace[i];
48 }
99e7186b 49 delete [] fParamSpace;
4cafa5fc 50}
51
e26acabd 52void AliL3HoughTransformer::CreateHistograms(Int_t nxbin,Double_t pt_min,
53 Int_t nybin,Double_t phimin,Double_t phimax)
54{
55 //Set the minimum absolute pt value, and phi0 angles given in degrees.
56
57 Double_t torad = 3.1415/180;
58 Double_t bfact = 0.0029980;
59 Double_t bfield = 0.2;
60 Double_t x = bfact*bfield/pt_min;
61 CreateHistograms(nxbin,-1.*x,x,nybin,phimin*torad,phimax*torad);
62}
63
99e7186b 64void AliL3HoughTransformer::CreateHistograms(Int_t nxbin,Double_t xmin,Double_t xmax,
65 Int_t nybin,Double_t ymin,Double_t ymax)
4cafa5fc 66{
4fc9a6a4 67
99e7186b 68 fParamSpace = new AliL3Histogram*[fNEtaSegments];
4cafa5fc 69
99e7186b 70 Char_t histname[256];
71 for(Int_t i=0; i<fNEtaSegments; i++)
4de874d1 72 {
99e7186b 73 sprintf(histname,"paramspace_%d",i);
74 fParamSpace[i] = new AliL3Histogram(histname,"",nxbin,xmin,xmax,nybin,ymin,ymax);
4de874d1 75 }
4cafa5fc 76}
77
e26acabd 78void AliL3HoughTransformer::Reset()
79{
48f3c46f 80 //Reset all the histograms
e26acabd 81
82 if(!fParamSpace)
83 {
84 LOG(AliL3Log::kWarning,"AliL3HoughTransformer::Reset","Histograms")
85 <<"No histograms to reset"<<ENDLOG;
86 return;
87 }
88
89 for(Int_t i=0; i<fNEtaSegments; i++)
90 fParamSpace[i]->Reset();
e26acabd 91}
92
99e7186b 93void AliL3HoughTransformer::SetInputData(UInt_t ndigits,AliL3DigitRowData *ptr)
9f33a1db 94{
99e7186b 95 fNDigitRowData = ndigits;
96 fDigitRowData = ptr;
4de874d1 97}
98
4fc9a6a4 99void AliL3HoughTransformer::TransformCircle()
4de874d1 100{
99e7186b 101 //Transform the input data with a circle HT.
102
52a2a604 103
99e7186b 104 //Set pointer to the data
105 AliL3DigitRowData *tempPt = (AliL3DigitRowData*)fDigitRowData;
106 if(!tempPt || fNDigitRowData==0)
4de874d1 107 {
4fc9a6a4 108 printf("\nAliL3HoughTransformer::TransformCircle : No input data!!!\n\n");
99e7186b 109 return;
4de874d1 110 }
99e7186b 111
112 Double_t etaslice = (fEtaMax - fEtaMin)/fNEtaSegments;
4cafa5fc 113 for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
114 {
99e7186b 115 AliL3DigitData *digPt = tempPt->fDigitData;
116 if(i != (Int_t)tempPt->fRow)
4cafa5fc 117 {
4fc9a6a4 118 printf("AliL3HoughTransform::TransformCircle : Mismatching padrow numbering\n");
99e7186b 119 continue;
120 }
121 for(UInt_t j=0; j<tempPt->fNDigit; j++)
122 {
123 UShort_t charge = digPt[j].fCharge;
124 UChar_t pad = digPt[j].fPad;
125 UShort_t time = digPt[j].fTime;
48f3c46f 126 if(charge <= fThreshold)
99e7186b 127 continue;
4cafa5fc 128 Int_t sector,row;
99e7186b 129 Float_t xyz[3];
4cafa5fc 130 fTransform->Slice2Sector(fSlice,i,sector,row);
99e7186b 131 fTransform->Raw2Local(xyz,sector,row,(Int_t)pad,(Int_t)time);
4fc9a6a4 132 Double_t eta = fTransform->GetEta(xyz);
48f3c46f 133 Int_t eta_index = (Int_t)((eta-fEtaMin)/etaslice);
99e7186b 134 if(eta_index < 0 || eta_index >= fNEtaSegments)
135 continue;
4cafa5fc 136
e26acabd 137 //Get the correct histogrampointer:
99e7186b 138 AliL3Histogram *hist = fParamSpace[eta_index];
139 if(!hist)
4cafa5fc 140 {
4fc9a6a4 141 printf("AliL3HoughTransformer::TransformCircle : Error getting histogram in index %d\n",eta_index);
99e7186b 142 continue;
4cafa5fc 143 }
4cafa5fc 144
99e7186b 145 //Start transformation
e26acabd 146 Float_t R = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]); // + xyz[2]*xyz[2]);
99e7186b 147 Float_t phi = fTransform->GetPhi(xyz);
4de874d1 148
99e7186b 149 //Fill the histogram along the phirange
150 for(Int_t b=hist->GetFirstYbin(); b<=hist->GetLastYbin(); b++)
4de874d1 151 {
99e7186b 152 Float_t phi0 = hist->GetBinCenterY(b);
153 Float_t kappa = 2*sin(phi - phi0)/R;
154 hist->Fill(kappa,phi0,charge);
4de874d1 155 }
4de874d1 156 }
48f3c46f 157 AliL3MemHandler::UpdateRowPointer(tempPt);
4de874d1 158 }
4de874d1 159}
160
4fc9a6a4 161void AliL3HoughTransformer::TransformLine()
162{
163 //Do a line transform on the data.
164
165
166 AliL3DigitRowData *tempPt = (AliL3DigitRowData*)fDigitRowData;
167 if(!tempPt || fNDigitRowData==0)
168 {
169 printf("\nAliL3HoughTransformer::TransformLine : No input data!!!\n\n");
170 return;
171 }
172
173 Double_t etaslice = (fEtaMax - fEtaMin)/fNEtaSegments;
174 for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
175 {
176 AliL3DigitData *digPt = tempPt->fDigitData;
177 if(i != (Int_t)tempPt->fRow)
178 {
179 printf("AliL3HoughTransform::TransformLine : Mismatching padrow numbering\n");
180 continue;
181 }
182 for(UInt_t j=0; j<tempPt->fNDigit; j++)
183 {
184 UShort_t charge = digPt[j].fCharge;
185 UChar_t pad = digPt[j].fPad;
186 UShort_t time = digPt[j].fTime;
187 if(charge < fThreshold)
188 continue;
189 Int_t sector,row;
190 Float_t xyz[3];
191 fTransform->Slice2Sector(fSlice,i,sector,row);
192 fTransform->Raw2Local(xyz,sector,row,(Int_t)pad,(Int_t)time);
193 Float_t eta = fTransform->GetEta(xyz);
194 Int_t eta_index = (Int_t)(eta/etaslice);
195 if(eta_index < 0 || eta_index >= fNEtaSegments)
196 continue;
197
198 //Get the correct histogram:
199 AliL3Histogram *hist = fParamSpace[eta_index];
200 if(!hist)
201 {
202 printf("AliL3HoughTransformer::TransformLine : Error getting histogram in index %d\n",eta_index);
203 continue;
204 }
205 for(Int_t xbin=hist->GetFirstXbin(); xbin<hist->GetLastXbin(); xbin++)
206 {
207 Double_t theta = hist->GetBinCenterX(xbin);
208 Double_t rho = xyz[0]*cos(theta) + xyz[1]*sin(theta);
209 hist->Fill(theta,rho,charge);
210 }
211 }
48f3c46f 212 AliL3MemHandler::UpdateRowPointer(tempPt);
4fc9a6a4 213 }
214
215}