1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
20 #include "AliRICHSegmentation.h"
23 ClassImp(AliRICHSegmentation)
25 //________________________________________________________________________________
26 AliRICHSegmentation::AliRICHSegmentation()
28 fNpx=144; // Number of pads in x direction
29 fNpy=160; // Number of pads in y direction
31 fDeadZone=3.0; // spacer between photocathod planes cm
32 fDpx=0.84; // Pad x size cm
33 fDpy=0.8; // Pad y size cm
34 fWireD=0.84/2; // cm set by SetDAnod
35 }//AliRICHSegmentation::ctor()
37 void AliRICHSegmentation::Init()
39 Float_t csi_length = fNpy*fDpy + fDeadZone;
40 Float_t csi_width = fNpx*fDpx + 2*fDeadZone;
42 fPadPlane_Width = (csi_width - 2*fDeadZone)/3;
43 fPadPlane_Length = (csi_length - fDeadZone)/2;
44 }//void AliRICHSegmentation::Init()
46 // calculate sector from x-y coordinates
48 Int_t AliRICHSegmentation::Sector(Float_t x, Float_t y)
50 // Calculate to which sector does the hit (x,y) belong
54 //Parametrized definition
58 if (x> fPadPlane_Width/2 +fDeadZone)
60 if ( x<fPadPlane_Width/2 +fDeadZone + fPadPlane_Width)
63 if (x< fPadPlane_Width/2)
65 if (x> -( fPadPlane_Width/2))
68 if (x< -( fPadPlane_Width/2 +fDeadZone))
70 if (x> -( fPadPlane_Width/2 +fDeadZone + fPadPlane_Width))
74 else if (y>fDeadZone/2)
76 if (x> fPadPlane_Width/2 +fDeadZone)
78 if (x< fPadPlane_Width/2 +fDeadZone + fPadPlane_Width)
81 if (x< fPadPlane_Width/2)
83 if (x> -( fPadPlane_Width/2))
86 if (x< -( fPadPlane_Width/2 +fDeadZone))
88 if (x> -( fPadPlane_Width/2 +fDeadZone + fPadPlane_Width))
94 }//Int_t AliRICHSegmentation::Sector(Float_t x, Float_t y)
97 void AliRICHSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
99 // real coordinates (x,y) -> (ix,iy) pad numbers
101 // Please check origin of pad numbering !!!
103 Int_t sector=Sector(x,y);
105 //printf("Sector: %d\n",sector);
109 //ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx);
110 //iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy);
111 ix = Int_t ((x-fDeadZone)/fDpx);
112 iy = Int_t ((y+fDeadZone/2)/fDpy)-1;
116 ix = Int_t ((x-fDeadZone)/fDpx);
117 iy = Int_t ((y-fDeadZone/2)/fDpy);
121 ix = (x>=0)? ix = Int_t (x/fDpx) : ix = Int_t (x/fDpx)-1;
122 iy = Int_t ((y+fDeadZone/2)/fDpy)-1;
126 ix = (x>=0)? ix = Int_t (x/fDpx) : ix = Int_t (x/fDpx)-1;
127 iy = Int_t ((y-fDeadZone/2)/fDpy);
131 ix = Int_t ((x+fDeadZone)/fDpx)-1;
132 iy = Int_t ((y+fDeadZone/2)/fDpy)-1;
136 ix = Int_t ((x+fDeadZone)/fDpx)-1;
137 iy = Int_t ((y-fDeadZone/2)/fDpy);
141 //ix = Int_t (x/fDpx);
142 //iy = Int_t (y/fDpy);
144 //ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx);
145 //iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy);
153 if (iy > fNpy) iy= fNpy;
154 if (iy < -fNpy) iy=-fNpy;
155 if (ix > fNpx) ix= fNpx;
156 if (ix < -fNpx) ix=-fNpx;
157 }//void AliRICHSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
160 void AliRICHSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
163 // pad numbers (ix,iy)->(x,y) real coordinates
169 Float_t padplane_width = fNpx/3;
175 if (ix >= padplane_width/2)
178 if (ix< padplane_width/2)
180 if (ix >= -(padplane_width/2))
185 if (ix < -(padplane_width/2))
193 if (ix >= padplane_width/2)
196 if (ix< padplane_width/2)
198 if (ix >= -(padplane_width/2))
203 if (ix < -(padplane_width/2))
210 x = Float_t(ix)*fDpx+fDpx/2+fDeadZone;
211 y = Float_t(iy)*fDpy+fDpy/2-fDeadZone/2;
215 x = Float_t(ix)*fDpx+fDpx/2+fDeadZone;
216 y = Float_t(iy)*fDpy+fDpy/2+fDeadZone/2;
220 x = (ix>=0) ? x = Float_t(ix)*fDpx+fDpx/2 : x = Float_t(ix)*fDpx+fDpx/2;
221 y = Float_t(iy)*fDpy+fDpy/2-fDeadZone/2;
225 x = (ix>=0) ? x = Float_t(ix)*fDpx+fDpx/2 : x = Float_t(ix)*fDpx+fDpx/2;
226 y = Float_t(iy)*fDpy+fDpy/2+fDeadZone/2;
230 x = Float_t(ix)*fDpx+fDpx/2-fDeadZone;
231 y = Float_t(iy)*fDpy+fDpy/2-fDeadZone/2;
235 x = Float_t(ix)*fDpx+fDpx/2-fDeadZone;
236 y = Float_t(iy)*fDpy+fDpy/2+fDeadZone/2;
239 }//void AliRICHSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
242 void AliRICHSegmentation::IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
245 // Calculates integration limits
251 }//void AliRICHSegmentation::IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
254 Int_t AliRICHSegmentation::SigGenCond(Float_t x,Float_t y,Float_t)
257 // Signal will be generated if particle crosses pad boundary or
258 // boundary between two wires.
260 GetPadI(x,y,ixt,iyt);
261 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
263 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
271 void AliRICHSegmentation::SigGenInit(Float_t x,Float_t y,Float_t)
274 // Initialises pad and wire position during stepping
277 GetPadI(x,y,fIxt,fIyt);
278 fIwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
282 Float_t AliRICHSegmentation::GetAnod(Float_t xhit) const
285 // Get anod wire closer to hit
287 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
292 void AliRICHSegmentation::SetHit(Float_t xhit, Float_t yhit)
295 // Find the wire position (center of charge distribution)
296 // Float_t x0a=GetAnod(xhit);
301 void AliRICHSegmentation::
302 SetPad(Int_t ix, Int_t iy)
305 // Move to pad ix, iy
307 GetPadC(ix,iy,fX,fY);
312 void AliRICHSegmentation::
313 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
317 // Find the wire position (center of charge distribution)
318 Float_t x0a=GetAnod(xhit);
322 // and take fNsigma*sigma around this center
323 Float_t x01=x0a - dx;
324 Float_t x02=x0a + dx;
325 Float_t y01=yhit - dy;
326 Float_t y02=yhit + dy;
328 // find the pads over which the charge distributes
329 GetPadI(x01,y01,fIxmin,fIymin);
330 GetPadI(x02,y02,fIxmax,fIymax);
332 // Set current pad to lower left corner
335 GetPadC(fIx,fIy,fX,fY);
338 //printf("fIx: %d, fIy: %d fX: %f, fY: %f\n",fIx,fIy,fX,fY);
341 void AliRICHSegmentation::NextPad()
343 //printf("\n Next Pad \n");
346 // Step to next pad in integration region
348 // if (fIx==-1) fIx++;
350 } else if (fIy <= fIymax) {
351 // if (fIy==-1) fIy++;
355 printf("\n Error: Stepping outside integration region\n ");
357 GetPadC(fIx,fIy,fX,fY);
360 Int_t AliRICHSegmentation::MorePads()
363 // Are there more pads in the integration region
365 //printf("\n More Pads ? \n");
368 if (fIx >= fIxmax && fIy >= fIymax) {
369 //printf("There are no more pads\n\n\n\n\n");
372 //printf("There are more pads\n\n");
379 void AliRICHSegmentation::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[7], Int_t Ylist[7])
381 //Is used for the cluster finder, include diagonal elements
382 *Nlist=4;Xlist[0]=Xlist[1]=iX;Xlist[2]=iX-1;Xlist[3]=iX+1;
383 Ylist[0]=iY-1;Ylist[1]=iY+1;Ylist[2]=Ylist[3]=iY;
384 }//void AliRICHSegmentation::Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[7], Int_t Ylist[7])
386 Float_t AliRICHSegmentation::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y, Int_t *dummy)
388 // Returns the square of the distance between 1 pad
389 // labelled by its Channel numbers and a coordinate
393 return (x-X)*(x-X) + (y-Y)*(y-Y);
394 }//Float_t AliRICHSegmentation::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y, Int_t *dummy)