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