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