3 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
4 //*-- Copyright © ASV
6 #include "AliL3StandardIncludes.h"
7 #include "AliL3HoughTest.h"
8 #include "AliL3ModelTrack.h"
9 #include "AliL3Transform.h"
10 #include "AliL3Histogram.h"
19 //_____________________________________________________________
23 ClassImp(AliL3HoughTest)
25 AliL3HoughTest::AliL3HoughTest()
31 AliL3HoughTest::~AliL3HoughTest()
37 Bool_t AliL3HoughTest::GenerateTrackData(Double_t pt,Double_t psi,Int_t sign,Int_t patch,Int_t minhits)
42 fData = new SimData[AliL3Transform::GetNRows(patch)];
43 memset(fData,0,AliL3Transform::GetNRows(patch)*sizeof(SimData));
45 AliL3ModelTrack *track = new AliL3ModelTrack();
49 track->SetCharge(sign);
50 track->SetFirstPoint(0,0,0);
51 track->CalculateHelix();
56 Int_t clustercharge=100;
58 for(Int_t i=AliL3Transform::GetFirstRow(patch); i<=AliL3Transform::GetLastRow(patch); i++)
62 if(!track->GetCrossingPoint(i,xyz))
65 Int_t rowindex = i - AliL3Transform::GetFirstRow(patch);
67 AliL3Transform::Slice2Sector(0,i,sector,row);
68 AliL3Transform::Local2Raw(xyz,sector,row);
70 if(xyz[1] < 0 || xyz[1] >= AliL3Transform::GetNPads(i))
73 track->SetPadHit(i,xyz[1]);
74 //cout<<i<<" "<<xyz[1]<<endl;
75 memset(temp,0,200*sizeof(Int_t));
76 Double_t xysigma = sqrt(track->GetParSigmaY2(i));
78 for(j=0; j<entries; j++)
80 Int_t pad = TMath::Nint(gRandom->Gaus(xyz[1],xysigma));
81 if(pad < 0 || pad >= AliL3Transform::GetNPads(i))
89 if(temp[j]==0) continue;
90 Int_t index = j - minpad;
91 if(index < 0 || index >= 10)
93 cerr<<"AliL3HoughTest::GenerateTrackData : Wrong index "<<index<<endl;
96 Int_t charge = clustercharge*temp[j]/entries;
101 fData[rowindex].pads[index]=charge;
102 fData[rowindex].npads++;
104 fData[rowindex].minpad=minpad;
107 if(hitcounter < minhits)
112 void AliL3HoughTest::Transform2Circle(AliL3Histogram *hist)
116 cerr<<"AliL3HoughTest::Transform : No data"<<endl;
119 Float_t R,phi,phi0,kappa,xyz[3];
120 Int_t pad,charge,sector,row;
121 for(Int_t i=AliL3Transform::GetFirstRow(fCurrentPatch); i<=AliL3Transform::GetLastRow(fCurrentPatch); i++)
123 Int_t rowindex = i - AliL3Transform::GetFirstRow(fCurrentPatch);
124 AliL3Transform::Slice2Sector(0,i,sector,row);
125 for(Int_t j=0; j<fData[rowindex].npads; j++)
127 pad = j + fData[rowindex].minpad;
128 charge = fData[rowindex].pads[j];
130 AliL3Transform::Raw2Local(xyz,sector,row,pad,0);
132 R = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
134 phi = AliL3Transform::GetPhi(xyz);
136 for(Int_t k=hist->GetFirstYbin(); k<=hist->GetLastYbin(); k++)
138 phi0 = hist->GetBinCenterY(k);
139 kappa = 2*sin(phi-phi0)/R;
140 hist->Fill(kappa,phi0,charge);
146 void AliL3HoughTest::Transform2CircleC(AliL3Histogram *hist)
150 cerr<<"AliL3HoughTest::TransformC : No data"<<endl;
153 Int_t pad1,pad2,charge1,charge2,sector,row;
154 Float_t r1,r2,phi1,phi2,phi_0,kappa,hit[3],hit2[3];
155 for(Int_t i=AliL3Transform::GetFirstRow(fCurrentPatch); i<=AliL3Transform::GetLastRow(fCurrentPatch); i++)
157 Int_t rowindex1 = i - AliL3Transform::GetFirstRow(fCurrentPatch);
158 for(Int_t d1=0; d1<fData[rowindex1].npads; d1++)
160 pad1 = d1 + fData[rowindex1].minpad;
161 charge1 = fData[rowindex1].pads[d1];
162 AliL3Transform::Slice2Sector(0,i,sector,row);
163 AliL3Transform::Raw2Local(hit,sector,row,pad1,0);
164 r1 = sqrt(hit[0]*hit[0]+hit[1]*hit[1]);
165 phi1 = atan2(hit[1],hit[0]);
167 for(Int_t j=i+1; j<=AliL3Transform::GetLastRow(fCurrentPatch); j++)
169 Int_t rowindex2 = j - AliL3Transform::GetFirstRow(fCurrentPatch);
170 for(Int_t d2=0; d2<fData[rowindex2].npads; d2++)
172 pad2 = d2 + fData[rowindex2].minpad;
173 charge2 = fData[rowindex2].pads[d2];
174 AliL3Transform::Slice2Sector(0,j,sector,row);
175 AliL3Transform::Raw2Local(hit2,sector,row,pad2,0);
176 r2 = sqrt(hit2[0]*hit2[0]+hit2[1]*hit2[1]);
177 phi2 = atan2(hit2[1],hit2[0]);
178 phi_0 = atan( (r2*sin(phi1) - r1*sin(phi2)) / (r2*cos(phi1) - r1*cos(phi2)) );
180 kappa = 2*sin(phi1-phi_0) / r1;
181 hist->Fill(kappa,phi_0,charge1+charge2);
188 void AliL3HoughTest::Transform2Line(AliL3Histogram *hist,Int_t *rowrange)
192 cerr<<"AliL3HoughTest::Transform2Line : No data"<<endl;
196 Int_t pad,charge,sector,row;
197 Float_t hit[3],theta,rho;
198 for(Int_t i=rowrange[0]; i<=rowrange[1]; i++)
200 Int_t rowindex = i - AliL3Transform::GetFirstRow(fCurrentPatch);
201 for(Int_t d=0; d<fData[rowindex].npads; d++)
203 pad = d + fData[rowindex].minpad;
204 charge = fData[rowindex].pads[d];
205 AliL3Transform::Slice2Sector(0,i,sector,row);
206 AliL3Transform::Raw2Local(hit,sector,row,pad,0);
208 hit[0] = hit[0] - AliL3Transform::Row2X(rowrange[0]);
210 for(Int_t xbin=hist->GetFirstXbin(); xbin<hist->GetLastXbin(); xbin++)
212 theta = hist->GetBinCenterX(xbin);
213 rho = hit[0]*cos(theta) + hit[1]*sin(theta);
214 hist->Fill(theta,rho,charge);
220 void AliL3HoughTest::Transform2LineC(AliL3Histogram *hist,Int_t *rowrange)
224 cerr<<"AliL3HoughTest::Transform2Line : No data"<<endl;
228 Int_t pad1,pad2,charge1,charge2,sector,row;
229 Float_t theta,rho,hit[3],hit2[3];
230 for(Int_t i=rowrange[0]; i<=rowrange[1]; i++)
232 Int_t rowindex1 = i - AliL3Transform::GetFirstRow(fCurrentPatch);
233 for(Int_t d1=0; d1<fData[rowindex1].npads; d1++)
235 pad1 = d1 + fData[rowindex1].minpad;
236 charge1 = fData[rowindex1].pads[d1];
237 AliL3Transform::Slice2Sector(0,i,sector,row);
238 AliL3Transform::Raw2Local(hit,sector,row,pad1,0);
240 hit[0] = hit[0] - AliL3Transform::Row2X(rowrange[0]);
242 for(Int_t j=i+1; j<=rowrange[1]; j++)
244 Int_t rowindex2 = j - AliL3Transform::GetFirstRow(fCurrentPatch);
245 for(Int_t d2=0; d2<fData[rowindex2].npads; d2++)
247 pad2 = d2 + fData[rowindex2].minpad;
248 charge2 = fData[rowindex2].pads[d2];
249 AliL3Transform::Slice2Sector(0,j,sector,row);
250 AliL3Transform::Raw2Local(hit2,sector,row,pad2,0);
252 hit2[0] = hit2[0] - AliL3Transform::Row2X(rowrange[0]);
254 theta = atan2(hit2[0]-hit[0],hit[1]-hit2[1]);
255 rho = hit[0]*cos(theta)+hit[1]*sin(theta);
256 hist->Fill(theta,rho,charge1+charge2);
264 void AliL3HoughTest::FillImage(TH2 *hist)
268 cerr<<"AliL3HoughTest::FillImage : No data to fill"<<endl;
271 for(Int_t i=AliL3Transform::GetFirstRow(fCurrentPatch); i<=AliL3Transform::GetLastRow(fCurrentPatch); i++)
273 Int_t rowindex = i - AliL3Transform::GetFirstRow(fCurrentPatch);
274 for(Int_t j=0; j<fData[rowindex].npads; j++)
276 Int_t pad = j + fData[rowindex].minpad;
277 Int_t charge = fData[rowindex].pads[j];
280 AliL3Transform::Slice2Sector(0,i,sector,row);
281 AliL3Transform::Raw2Local(xyz,sector,row,pad,0);
282 hist->Fill(xyz[0],xyz[1],charge);