]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHSegmentationV0.cxx
Use AliSegmentation and AliHit abstract base classes.
[u/mrichter/AliRoot.git] / RICH / AliRICHSegmentationV0.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 /*
17   $Log$
18   Revision 1.2  2000/10/02 15:48:19  jbarbosa
19   Fixed coding conventions.
20
21   Revision 1.1  2000/06/12 15:31:54  jbarbosa
22   Cleaned up version.
23
24 */
25 #include "AliRICHSegmentationV0.h"
26
27
28 ClassImp(AliRICHSegmentationV0)
29
30 void AliRICHSegmentationV0::Init(Int_t id)
31 {
32
33 // Initialisation of chambers
34
35   fNpx=160;
36   fNpy=144;
37   //fNpx=80;
38   //fNpy=48;
39   fSector=-1;
40 }
41
42
43 Float_t AliRICHSegmentationV0::GetAnod(Float_t xhit) const
44 {
45
46 // Get anod wire closer to hit
47
48     Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
49     return fWireD*wire;
50 }
51
52 void AliRICHSegmentationV0::SetPadSize(Float_t p1, Float_t p2)
53 {
54
55 // Set the pad size
56
57     fDpx=p1;
58     fDpy=p2;
59 }
60 void AliRICHSegmentationV0::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
61 {
62 //  returns pad coordinates (ix,iy) for given real coordinates (x,y)
63 //
64 // Please check origin of pad numbering !!!
65
66   
67   ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx);
68   iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy);
69   if (iy >  fNpy) iy= fNpy;
70   if (iy < -fNpy) iy=-fNpy;
71   if (ix >  fNpx) ix= fNpx;
72   if (ix < -fNpx) ix=-fNpx;
73 }
74 void AliRICHSegmentationV0::
75 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
76 {
77 //  returns real coordinates (x,y) for given pad coordinates (ix,iy)
78 //
79
80   x = (ix>0) ? Float_t(ix*fDpx)-fDpx/2. : Float_t(ix*fDpx)-fDpx/2.;
81   y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)-fDpy/2.;
82 }
83
84 void AliRICHSegmentationV0::
85 SetHit(Float_t xhit, Float_t yhit)
86 {
87 //
88 // Find the wire position (center of charge distribution)
89 //    Float_t x0a=GetAnod(xhit);
90     fXhit=xhit;
91     fYhit=yhit;
92 }
93
94 void AliRICHSegmentationV0::
95 SetPad(Int_t ix, Int_t iy)
96 {
97
98 // Move to pad ix, iy
99
100     GetPadC(ix,iy,fX,fY);
101 }
102
103
104
105 void AliRICHSegmentationV0::
106 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
107 {
108
109     //
110     // Find the wire position (center of charge distribution)
111     Float_t x0a=GetAnod(xhit);
112     fXhit=x0a;
113     fYhit=yhit;
114     //
115     // and take fNsigma*sigma around this center
116     Float_t x01=x0a  - dx;
117     Float_t x02=x0a  + dx;
118     Float_t y01=yhit - dy;
119     Float_t y02=yhit + dy;
120     //
121     // find the pads over which the charge distributes
122     GetPadI(x01,y01,fIxmin,fIymin);
123     GetPadI(x02,y02,fIxmax,fIymax);    
124     // 
125     // Set current pad to lower left corner
126     fIx=fIxmin;
127     fIy=fIymin;
128     GetPadC(fIx,fIy,fX,fY);
129     
130     //if (fSector==2)
131       //printf("fIx: %d, fIy: %d fX: %f, fY: %f\n",fIx,fIy,fX,fY);
132 }
133
134 void AliRICHSegmentationV0::NextPad()
135 {
136     //printf("\n Next Pad \n");
137     
138     // 
139     // Step to next pad in integration region
140     if (fIx <= fIxmax) {
141 //      if (fIx==-1) fIx++;
142         fIx++;
143     } else if (fIy <= fIymax) {
144 //      if (fIy==-1) fIy++;
145         fIx=fIxmin;
146         fIy++;
147     } else {
148         printf("\n Error: Stepping outside integration region\n ");
149     }
150     GetPadC(fIx,fIy,fX,fY);
151 }
152
153 Int_t AliRICHSegmentationV0::MorePads()
154
155 {
156 //
157 // Are there more pads in the integration region
158
159     //printf("\n More  Pads ? \n");
160   
161   
162   if (fIx >= fIxmax && fIy >= fIymax) {
163     //printf("There are no more pads\n\n\n\n\n");
164     return 0;
165   } else {
166     //printf("There are more pads\n\n");
167     return 1;
168   }
169 }
170
171 void AliRICHSegmentationV0::SigGenInit(Float_t x,Float_t y,Float_t)
172 {
173 //
174 //  Initialises pad and wire position during stepping
175     fXt =x;
176     fYt =y;
177     GetPadI(x,y,fIxt,fIyt);
178     fIwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
179 }
180
181 Int_t AliRICHSegmentationV0::SigGenCond(Float_t x,Float_t y,Float_t)
182 {
183 //
184 //  Signal will be generated if particle crosses pad boundary or
185 //  boundary between two wires. 
186     Int_t ixt, iyt;
187     GetPadI(x,y,ixt,iyt);
188     Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
189     
190     if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
191       return 1;
192     } else {
193       return 0;
194     }
195 }
196 void AliRICHSegmentationV0::
197 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
198 {
199
200 // Calculate the integration limits
201
202 /*
203   x1=fXt-fX-fDpx/2.;
204   x2=x1+fDpx;
205   y1=fYt-fY-fDpy/2.;
206   y2=y1+fDpy;    
207 */
208   x1=fXhit-fX-fDpx/2.;
209   x2=x1+fDpx;
210   y1=fYhit-fY-fDpy/2.;
211   y2=y1+fDpy;
212 }
213
214 void AliRICHSegmentationV0::
215 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[7], Int_t Ylist[7])
216 {
217 //Is used for the cluster finder, include diagonal elements
218     
219     *Nlist=4;Xlist[0]=Xlist[1]=iX;Xlist[2]=iX-1;Xlist[3]=iX+1;
220     Ylist[0]=iY-1;Ylist[1]=iY+1;Ylist[2]=Ylist[3]=iY;
221 /*
222     *Nlist=8;
223     Xlist[0]=Xlist[1]=iX;
224     Xlist[2]=iX-1;
225     Xlist[3]=iX+1;
226     Ylist[0]=iY-1;
227     Ylist[1]=iY+1;
228     Ylist[2]=Ylist[3]=iY;
229
230    // Diagonal elements
231     Xlist[4]=iX+1;
232     Ylist[4]=iY+1;
233
234     Xlist[5]=iX-1;
235     Ylist[5]=iY-1;
236
237     Xlist[6]=iX-1;
238     Ylist[6]=iY+1;
239
240     Xlist[7]=iX+1;
241     Ylist[7]=iY-1;
242 */
243 }
244
245 Float_t AliRICHSegmentationV0::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y
246 , Int_t *dummy)
247
248 {
249 // Returns the square of the distance between 1 pad
250 // labelled by its Channel numbers and a coordinate
251
252   Float_t x,y;
253   GetPadC(iX,iY,x,y);
254   return (x-X)*(x-X) + (y-Y)*(y-Y);
255 }
256
257
258 void  AliRICHSegmentationV0::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y) const
259 {
260
261 // Test
262
263     n=1;
264     x[0]=0.;
265     y[0]=x[0];
266 }
267
268 void AliRICHSegmentationV0::Draw(const char* opt) const
269 {
270
271 // Dummy draw routine
272
273 /*
274     TArc *circle;
275     Float_t scale=0.95/fRmax/2.;
276     
277
278     circle = new TArc(0.5,0.5,fRmax*scale,0.,360.);
279     circle->SetFillColor(2);
280     circle->Draw();
281
282     circle = new TArc(0.5,0.5,fRmin*scale,0.,360.);
283     circle->SetFillColor(1);
284     circle->Draw();
285 */
286     ;
287     
288 }