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