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