]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHSegmentationV1.cxx
some cleaning
[u/mrichter/AliRoot.git] / RICH / AliRICHSegmentationV1.cxx
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 /* $Id$ */
17
18 #include "AliRICHSegmentationV1.h"
19
20 ClassImp(AliRICHSegmentationV1)
21
22 AliRICHSegmentationV1::AliRICHSegmentationV1()
23
24
25 // Default constructor for AliRICHSegmantionV1 (with dead zones)
26
27    fNpx=144;      // number of pads along X direction 
28    fNpy=160;      // number of pads along Y direction 
29    fDeadZone=3.0; // space between CsI photocathods in cm
30    fDpx=0.84;     // pad width in cm
31    fDpy=0.80;     // pad heights in cm
32    fWireD=0.84/2;        
33    fSector=-1;
34    Init(0);       // ??? remove 0
35 }
36
37 void AliRICHSegmentationV1::Init(Int_t /*id*/)
38 {//Recalculates all the values after some of them have been changed
39     
40    Float_t csi_length = fNpy*fDpy + fDeadZone;
41    Float_t csi_width = fNpx*fDpx + 2*fDeadZone;
42
43    fPadPlane_Width = (csi_width - 2*fDeadZone)/3;
44    fPadPlane_Length = (csi_length - fDeadZone)/2;
45 }
46
47 // calculate sector from x-y coordinates
48
49 Int_t AliRICHSegmentationV1::Sector(Float_t x, Float_t y)
50 {
51
52 // Calculate in which sector is the hit
53   
54   fSector=-1;
55   
56   //old numerical definition
57
58   /*if (x<-fDeadZone/2)
59     {
60       if (y>22.75)
61         {
62           if (y<63.1)
63             fSector=0;
64         }
65       if (y<20.15)
66         {
67           if (y>(-20.15))
68             fSector=2;
69         }
70       if (y<(-22.75))
71         {
72           if (y>(-63.1))
73             fSector=4;
74         }
75     }
76   else if (x>fDeadZone/2)
77     {
78       if (y>22.75)
79         {
80           if (y<63.1)
81             fSector=1;
82         }
83       if (y<20.15)
84         {
85           if (y>(-20.15))
86             fSector=3;
87         }
88       if (y<(-22.75))
89         {
90           if (y>(-63.1))
91             fSector=5;
92         }
93     }*/
94
95   //Parametrized definition
96
97   if (y<-fDeadZone/2)
98     {
99       if (x> fPadPlane_Width/2 +fDeadZone)
100         {
101           if ( x<fPadPlane_Width/2 +fDeadZone + fPadPlane_Width)
102             fSector=0;
103         }
104       if (x< fPadPlane_Width/2)
105         {
106           if (x> -( fPadPlane_Width/2))
107             fSector=2;
108         }
109       if (x< -( fPadPlane_Width/2 +fDeadZone))
110         {
111           if (x> -( fPadPlane_Width/2 +fDeadZone +  fPadPlane_Width))
112             fSector=4;
113         }
114     }
115   else if (y>fDeadZone/2)
116     {
117       if (x> fPadPlane_Width/2 +fDeadZone)
118         {
119           if (x< fPadPlane_Width/2 +fDeadZone +  fPadPlane_Width)
120             fSector=1;
121         }
122       if (x< fPadPlane_Width/2)
123         {
124           if (x> -( fPadPlane_Width/2))
125             fSector=3;
126         }
127       if (x< -( fPadPlane_Width/2 +fDeadZone))
128         {
129           if (x> -( fPadPlane_Width/2 +fDeadZone +  fPadPlane_Width))
130             fSector=5;
131         }
132     }
133
134   
135   //if (fSector==2)
136     //printf("x:%f, y:%f, sector:%d\n",x,y,fSector);
137
138   return fSector;
139 }
140
141
142 void AliRICHSegmentationV1::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
143 {
144 //  returns pad coordinates (ix,iy) for given real coordinates (x,y)
145 //
146 // Please check origin of pad numbering !!!
147
148   ix=9999; //PH Fake values which should not be returned
149   iy=9999;
150
151   Int_t sector=Sector(x,y);
152
153   //printf("Sector: %d\n",sector);
154
155   if (sector==0)
156     {
157       //ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx);
158       //iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy);
159       ix = Int_t ((x-fDeadZone)/fDpx);
160       iy = Int_t ((y+fDeadZone/2)/fDpy)-1;
161     }
162   if (sector==1)
163     {
164       ix = Int_t ((x-fDeadZone)/fDpx);
165       iy = Int_t ((y-fDeadZone/2)/fDpy);
166     }
167   if (sector==2)
168     {
169       ix = (x>=0)? ix = Int_t (x/fDpx) : ix = Int_t (x/fDpx)-1;
170       iy = Int_t ((y+fDeadZone/2)/fDpy)-1;
171     }
172   if (sector==3)
173     {
174       ix = (x>=0)? ix = Int_t (x/fDpx) : ix = Int_t (x/fDpx)-1;
175       iy = Int_t ((y-fDeadZone/2)/fDpy);
176     }
177   if (sector==4)
178     {
179       ix = Int_t ((x+fDeadZone)/fDpx)-1;
180       iy = Int_t ((y+fDeadZone/2)/fDpy)-1;
181     }
182   if (sector==5)
183     {
184       ix = Int_t ((x+fDeadZone)/fDpx)-1;
185       iy = Int_t ((y-fDeadZone/2)/fDpy);
186     }
187
188   
189   //ix = Int_t (x/fDpx);
190   //iy = Int_t (y/fDpy);
191
192   //ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx);
193   //iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy);
194
195   if (sector==-1)
196     {
197       ix = fIxmax;
198       iy = fIymax;
199     }
200
201   if (iy >  fNpy) iy= fNpy;
202   if (iy < -fNpy) iy=-fNpy;
203   if (ix >  fNpx) ix= fNpx;
204   if (ix < -fNpx) ix=-fNpx;
205 }
206
207 void AliRICHSegmentationV1::
208 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
209 {
210 //  returns real coordinates (x,y) for given pad coordinates (ix,iy)
211 //
212
213   //Int_t sector=Sector(ix*.8,iy*.84);
214
215   Int_t sector=-1;
216
217  // old numerical definition
218
219  /*if (ix<=0)
220     {
221       if (iy<=72)
222         {
223           if (iy>24)
224             sector=0;
225         }
226       if (iy<=24)
227         {
228           if (iy>-24)
229             sector=2;
230         }
231       if (iy<=-24)
232         {
233           if (iy>-72)
234             sector=4;
235         }
236     }
237   if (ix>0)
238     {
239       if (iy<=72)
240         {
241           if (iy>24)
242             sector=1;
243         }
244       if (iy<=24)
245         {
246           if (iy>-24)
247             sector=3;
248         }
249       if (iy<=-24)
250         {
251           if (iy>-72)
252             sector=5;
253         }
254     }*/
255   
256   //  parametrised definition
257
258   Float_t padplane_width = fNpx/3;
259   
260   if (iy<0)
261     {
262       if (ix < fNpx/2)
263         {
264           if (ix >= padplane_width/2)
265             sector=0;
266         }
267       if (ix< padplane_width/2)
268         {
269           if (ix >= -(padplane_width/2))
270             sector=2;
271         }
272       if (ix >= -(fNpx/2))
273         {
274           if (ix < -(padplane_width/2))
275             sector=4;
276         }
277     }
278   if (iy>=0)
279     {
280       if (ix < fNpx/2)
281         {
282           if (ix >= padplane_width/2)
283             sector=1;
284         }
285       if (ix< padplane_width/2)
286         {
287           if (ix >= -(padplane_width/2))
288             sector=3;
289         }
290       if (ix >= -(fNpx/2))
291         {
292           if (ix < -(padplane_width/2))
293             sector=5;
294         }
295     }
296
297   if (sector==0)
298     {
299       //x = (ix>0) ? Float_t(ix*fDpx)-fDpx/2. : Float_t(ix*fDpx)-fDpx/2.;
300       //y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)-fDpy/2.;
301       x = Float_t(ix)*fDpx+fDpx/2+fDeadZone;
302       y = Float_t(iy)*fDpy+fDpy/2-fDeadZone/2;
303     }
304   if (sector==1)
305     {
306       x = Float_t(ix)*fDpx+fDpx/2+fDeadZone;
307       y = Float_t(iy)*fDpy+fDpy/2+fDeadZone/2;
308     }
309   if (sector==2)
310     {
311       x = (ix>=0) ? x = Float_t(ix)*fDpx+fDpx/2 : x = Float_t(ix)*fDpx+fDpx/2;
312       y = Float_t(iy)*fDpy+fDpy/2-fDeadZone/2;
313     }
314   if (sector==3)
315     {
316       x = (ix>=0) ? x = Float_t(ix)*fDpx+fDpx/2 : x = Float_t(ix)*fDpx+fDpx/2;
317       y = Float_t(iy)*fDpy+fDpy/2+fDeadZone/2;
318     }
319   if (sector==4)
320     {
321       x = Float_t(ix)*fDpx+fDpx/2-fDeadZone;
322       y = Float_t(iy)*fDpy+fDpy/2-fDeadZone/2;
323     }
324   if (sector==5)
325     {
326       x = Float_t(ix)*fDpx+fDpx/2-fDeadZone;
327       y = Float_t(iy)*fDpy+fDpy/2+fDeadZone/2;
328     }
329  
330   
331   //if (sector==2)
332     //printf("fSector:%d x:%f y:%f\n",fSector,x,y);
333   
334 }
335
336 void AliRICHSegmentationV1::
337 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
338 {
339
340 // Calculates integration limits
341
342 /*
343   x1=fXt-fX-fDpx/2.;
344   x2=x1+fDpx;
345   y1=fYt-fY-fDpy/2.;
346   y2=y1+fDpy;    
347 */
348   //Int_t sector=Sector(fX,fY);
349
350   //printf("Sector:%d\n",sector);
351
352   x1=fXhit-fX-fDpx/2.;
353   x2=x1+fDpx;
354   y1=fYhit-fY-fDpy/2.;
355   y2=y1+fDpy;
356 }
357
358
359
360
361
362