Increment the version number
[u/mrichter/AliRoot.git] / RICH / AliRICHSegmentation.cxx
CommitLineData
c4ac64b6 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/*
17 $Log$
18*/
19
20#include "AliRICHSegmentation.h"
21
22
23ClassImp(AliRICHSegmentation)
24
25//________________________________________________________________________________
26AliRICHSegmentation::AliRICHSegmentation()
27{
28 fNpx=144; // Number of pads in x direction
29 fNpy=160; // Number of pads in y direction
30 fSector=-1;
31 fDeadZone=3.0; // spacer between photocathod planes cm
32 fDpx=0.84; // Pad x size cm
33 fDpy=0.8; // Pad y size cm
34 fWireD=0.84/2; // cm set by SetDAnod
35}//AliRICHSegmentation::ctor()
36
37void AliRICHSegmentation::Init()
38{
39 Float_t csi_length = fNpy*fDpy + fDeadZone;
40 Float_t csi_width = fNpx*fDpx + 2*fDeadZone;
41
42 fPadPlane_Width = (csi_width - 2*fDeadZone)/3;
43 fPadPlane_Length = (csi_length - fDeadZone)/2;
44}//void AliRICHSegmentation::Init()
45
46// calculate sector from x-y coordinates
47
48Int_t AliRICHSegmentation::Sector(Float_t x, Float_t y)
49{
50// Calculate to which sector does the hit (x,y) belong
51
52 fSector=-1;
53
54 //Parametrized definition
55
56 if (y<-fDeadZone/2)
57 {
58 if (x> fPadPlane_Width/2 +fDeadZone)
59 {
60 if ( x<fPadPlane_Width/2 +fDeadZone + fPadPlane_Width)
61 fSector=0;
62 }
63 if (x< fPadPlane_Width/2)
64 {
65 if (x> -( fPadPlane_Width/2))
66 fSector=2;
67 }
68 if (x< -( fPadPlane_Width/2 +fDeadZone))
69 {
70 if (x> -( fPadPlane_Width/2 +fDeadZone + fPadPlane_Width))
71 fSector=4;
72 }
73 }
74 else if (y>fDeadZone/2)
75 {
76 if (x> fPadPlane_Width/2 +fDeadZone)
77 {
78 if (x< fPadPlane_Width/2 +fDeadZone + fPadPlane_Width)
79 fSector=1;
80 }
81 if (x< fPadPlane_Width/2)
82 {
83 if (x> -( fPadPlane_Width/2))
84 fSector=3;
85 }
86 if (x< -( fPadPlane_Width/2 +fDeadZone))
87 {
88 if (x> -( fPadPlane_Width/2 +fDeadZone + fPadPlane_Width))
89 fSector=5;
90 }
91 }
92
93 return fSector;
94}//Int_t AliRICHSegmentation::Sector(Float_t x, Float_t y)
95
96
97void AliRICHSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
98{
99// real coordinates (x,y) -> (ix,iy) pad numbers
100//
101// Please check origin of pad numbering !!!
102
103 Int_t sector=Sector(x,y);
104
105 //printf("Sector: %d\n",sector);
106
107 if (sector==0)
108 {
109 //ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx);
110 //iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy);
111 ix = Int_t ((x-fDeadZone)/fDpx);
112 iy = Int_t ((y+fDeadZone/2)/fDpy)-1;
113 }
114 if (sector==1)
115 {
116 ix = Int_t ((x-fDeadZone)/fDpx);
117 iy = Int_t ((y-fDeadZone/2)/fDpy);
118 }
119 if (sector==2)
120 {
121 ix = (x>=0)? ix = Int_t (x/fDpx) : ix = Int_t (x/fDpx)-1;
122 iy = Int_t ((y+fDeadZone/2)/fDpy)-1;
123 }
124 if (sector==3)
125 {
126 ix = (x>=0)? ix = Int_t (x/fDpx) : ix = Int_t (x/fDpx)-1;
127 iy = Int_t ((y-fDeadZone/2)/fDpy);
128 }
129 if (sector==4)
130 {
131 ix = Int_t ((x+fDeadZone)/fDpx)-1;
132 iy = Int_t ((y+fDeadZone/2)/fDpy)-1;
133 }
134 if (sector==5)
135 {
136 ix = Int_t ((x+fDeadZone)/fDpx)-1;
137 iy = Int_t ((y-fDeadZone/2)/fDpy);
138 }
139
140
141 //ix = Int_t (x/fDpx);
142 //iy = Int_t (y/fDpy);
143
144 //ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx);
145 //iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy);
146
147 if (sector==-1)
148 {
149 ix = fIxmax;
150 iy = fIymax;
151 }
152
153 if (iy > fNpy) iy= fNpy;
154 if (iy < -fNpy) iy=-fNpy;
155 if (ix > fNpx) ix= fNpx;
156 if (ix < -fNpx) ix=-fNpx;
157}//void AliRICHSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
158
159
160void AliRICHSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
161{
162//
163// pad numbers (ix,iy)->(x,y) real coordinates
164//
165
166 Int_t sector=-1;
167
168
169 Float_t padplane_width = fNpx/3;
170
171 if (iy<0)
172 {
173 if (ix < fNpx/2)
174 {
175 if (ix >= padplane_width/2)
176 sector=0;
177 }
178 if (ix< padplane_width/2)
179 {
180 if (ix >= -(padplane_width/2))
181 sector=2;
182 }
183 if (ix >= -(fNpx/2))
184 {
185 if (ix < -(padplane_width/2))
186 sector=4;
187 }
188 }
189 if (iy>=0)
190 {
191 if (ix < fNpx/2)
192 {
193 if (ix >= padplane_width/2)
194 sector=1;
195 }
196 if (ix< padplane_width/2)
197 {
198 if (ix >= -(padplane_width/2))
199 sector=3;
200 }
201 if (ix >= -(fNpx/2))
202 {
203 if (ix < -(padplane_width/2))
204 sector=5;
205 }
206 }
207
208 if (sector==0)
209 {
210 x = Float_t(ix)*fDpx+fDpx/2+fDeadZone;
211 y = Float_t(iy)*fDpy+fDpy/2-fDeadZone/2;
212 }
213 if (sector==1)
214 {
215 x = Float_t(ix)*fDpx+fDpx/2+fDeadZone;
216 y = Float_t(iy)*fDpy+fDpy/2+fDeadZone/2;
217 }
218 if (sector==2)
219 {
220 x = (ix>=0) ? x = Float_t(ix)*fDpx+fDpx/2 : x = Float_t(ix)*fDpx+fDpx/2;
221 y = Float_t(iy)*fDpy+fDpy/2-fDeadZone/2;
222 }
223 if (sector==3)
224 {
225 x = (ix>=0) ? x = Float_t(ix)*fDpx+fDpx/2 : x = Float_t(ix)*fDpx+fDpx/2;
226 y = Float_t(iy)*fDpy+fDpy/2+fDeadZone/2;
227 }
228 if (sector==4)
229 {
230 x = Float_t(ix)*fDpx+fDpx/2-fDeadZone;
231 y = Float_t(iy)*fDpy+fDpy/2-fDeadZone/2;
232 }
233 if (sector==5)
234 {
235 x = Float_t(ix)*fDpx+fDpx/2-fDeadZone;
236 y = Float_t(iy)*fDpy+fDpy/2+fDeadZone/2;
237 }
238
239}//void AliRICHSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
240
241
242void AliRICHSegmentation::IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
243{
244
245// Calculates integration limits
246
247 x1=fXhit-fX-fDpx/2.;
248 x2=x1+fDpx;
249 y1=fYhit-fY-fDpy/2.;
250 y2=y1+fDpy;
251}//void AliRICHSegmentation::IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
252
253
254Int_t AliRICHSegmentation::SigGenCond(Float_t x,Float_t y,Float_t)
255{
256//
257// Signal will be generated if particle crosses pad boundary or
258// boundary between two wires.
259 Int_t ixt, iyt;
260 GetPadI(x,y,ixt,iyt);
261 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
262
263 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
264 return 1;
265 } else {
266 return 0;
267 }
268}
269
270
271void AliRICHSegmentation::SigGenInit(Float_t x,Float_t y,Float_t)
272{
273//
274// Initialises pad and wire position during stepping
275 fXt =x;
276 fYt =y;
277 GetPadI(x,y,fIxt,fIyt);
278 fIwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
279}
280
281
282Float_t AliRICHSegmentation::GetAnod(Float_t xhit) const
283{
284
285// Get anod wire closer to hit
286
287 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
288 return fWireD*wire;
289}
290
291
292void AliRICHSegmentation::SetHit(Float_t xhit, Float_t yhit)
293{
294//
295// Find the wire position (center of charge distribution)
296// Float_t x0a=GetAnod(xhit);
297 fXhit=xhit;
298 fYhit=yhit;
299}
300
301void AliRICHSegmentation::
302SetPad(Int_t ix, Int_t iy)
303{
304
305// Move to pad ix, iy
306
307 GetPadC(ix,iy,fX,fY);
308}
309
310
311
312void AliRICHSegmentation::
313FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
314{
315
316 //
317 // Find the wire position (center of charge distribution)
318 Float_t x0a=GetAnod(xhit);
319 fXhit=x0a;
320 fYhit=yhit;
321 //
322 // and take fNsigma*sigma around this center
323 Float_t x01=x0a - dx;
324 Float_t x02=x0a + dx;
325 Float_t y01=yhit - dy;
326 Float_t y02=yhit + dy;
327 //
328 // find the pads over which the charge distributes
329 GetPadI(x01,y01,fIxmin,fIymin);
330 GetPadI(x02,y02,fIxmax,fIymax);
331 //
332 // Set current pad to lower left corner
333 fIx=fIxmin;
334 fIy=fIymin;
335 GetPadC(fIx,fIy,fX,fY);
336
337 //if (fSector==2)
338 //printf("fIx: %d, fIy: %d fX: %f, fY: %f\n",fIx,fIy,fX,fY);
339}
340
341void AliRICHSegmentation::NextPad()
342{
343 //printf("\n Next Pad \n");
344
345 //
346 // Step to next pad in integration region
347 if (fIx <= fIxmax) {
348// if (fIx==-1) fIx++;
349 fIx++;
350 } else if (fIy <= fIymax) {
351// if (fIy==-1) fIy++;
352 fIx=fIxmin;
353 fIy++;
354 } else {
355 printf("\n Error: Stepping outside integration region\n ");
356 }
357 GetPadC(fIx,fIy,fX,fY);
358}
359
360Int_t AliRICHSegmentation::MorePads()
361{
362//
363// Are there more pads in the integration region
364
365 //printf("\n More Pads ? \n");
366
367
368 if (fIx >= fIxmax && fIy >= fIymax) {
369 //printf("There are no more pads\n\n\n\n\n");
370 return 0;
371 } else {
372 //printf("There are more pads\n\n");
373 return 1;
374 }
375}
376
377
378
379void AliRICHSegmentation::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[7], Int_t Ylist[7])
380{
381//Is used for the cluster finder, include diagonal elements
382 *Nlist=4;Xlist[0]=Xlist[1]=iX;Xlist[2]=iX-1;Xlist[3]=iX+1;
383 Ylist[0]=iY-1;Ylist[1]=iY+1;Ylist[2]=Ylist[3]=iY;
384}//void AliRICHSegmentation::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[7], Int_t Ylist[7])
385
386Float_t AliRICHSegmentation::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y, Int_t *dummy)
387{
388// Returns the square of the distance between 1 pad
389// labelled by its Channel numbers and a coordinate
390
391 Float_t x,y;
392 GetPadC(iX,iY,x,y);
393 return (x-X)*(x-X) + (y-Y)*(y-Y);
394}//Float_t AliRICHSegmentation::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y, Int_t *dummy)