]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSegmentationV0.cxx
Radius of PHOS equal to 460 (Y.Schutz)
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentationV0.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 "AliMUONSegmentationV0.h"
19 #include "TArc.h"
20 #include "TMath.h"
21 #include "AliMUONChamber.h"
22 #include "AliRun.h"
23 #include "AliMUON.h"
24
25 ClassImp(AliMUONSegmentationV0)
26   AliMUONSegmentationV0::AliMUONSegmentationV0(const AliMUONSegmentationV0& segmentation):AliSegmentation(segmentation)
27 {
28   // Dummy copy constructor
29 }
30
31     void AliMUONSegmentationV0::Init(Int_t  chamber)
32 {
33 //  Initialises member data of the segmentation from geometry data 
34 //  owned by Chamber
35 //
36     AliMUON *pMUON  = (AliMUON *) gAlice->GetModule("MUON");
37     fChamber=&(pMUON->Chamber(chamber));
38     
39 //  Initialise maximum number of pads in x ans y
40     fNpx=(Int_t) (fChamber->ROuter()/fDpx+1);
41     fNpy=(Int_t) (fChamber->ROuter()/fDpy+1);
42 //  Initialize inner and outer radius of the sensitive region     
43     fRmin=fChamber->RInner();
44     fRmax=fChamber->ROuter();    
45     fCorr=0;
46     fZ=fChamber->Z();
47     fId=chamber;
48 }
49
50
51 Float_t AliMUONSegmentationV0::GetAnod(Float_t xhit) const
52 {
53 // Returns for a hit position xhit the position of the nearest anode wire    
54     Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
55     return fWireD*wire;
56 }
57 //____________________________________________________________________________
58 void   AliMUONSegmentationV0::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/, Int_t *Nparallel, Int_t *Offset) 
59 {
60   *Nparallel=1;
61   *Offset=0;
62 }
63
64
65 //____________________________________________________________________________
66 void   AliMUONSegmentationV0::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)  
67 {
68   GetPadI(x, y, ix, iy);
69 }
70 //____________________________________________________________________________
71 void   AliMUONSegmentationV0::SetCorrFunc(Int_t /*dum*/, TF1* func) 
72 {
73   fCorr=func;
74 }
75 //____________________________________________________________________________
76 Int_t   AliMUONSegmentationV0::Sector(Int_t /*ix*/, Int_t /*iy*/)  
77 {
78   return 1;
79 }
80 //____________________________________________________________________________
81 Int_t   AliMUONSegmentationV0::Sector(Float_t /*x*/, Float_t /*y*/)  
82 {
83   return 1;
84 }
85 //____________________________________________________________________________
86 void AliMUONSegmentationV0::SetPadSize(Float_t p1, Float_t p2)
87 {
88 //  Sets the padsize 
89 //  
90     fDpx=p1;
91     fDpy=p2;
92 }
93
94 void AliMUONSegmentationV0::
95     GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy) 
96 {
97 //  Returns pad coordinates (ix,iy) for given real coordinates (x,y)
98 //
99     ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx)-1;
100     iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy)-1;
101     if (iy >  fNpy) iy= fNpy;
102     if (iy < -fNpy) iy=-fNpy;
103     if (ix >  fNpx) ix= fNpx;
104     if (ix < -fNpx) ix=-fNpx;
105 }
106
107 void AliMUONSegmentationV0::
108 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y) 
109 {
110 //  Returns real coordinates (x,y) for given pad coordinates (ix,iy)
111 //
112 // Comments and Critics: 
113
114 //  The Pad(0,0) does not exist, this causes in the present version errors 
115 //  during iteration when used with hits close to zero.
116 //  Since we have frame crosses at  x=0 or y=0 this does not cause any problems
117 //  Nevertheless, should be corrected in the  next version !!
118 //  The name fRmin is misleading although we use this version with 
119 //  a circular chamber geometry.
120
121     x = (ix>0) ? Float_t(ix*fDpx)-fDpx/2. : Float_t(ix*fDpx)+fDpx/2.;
122     y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)+fDpy/2.;
123 }
124 //______________________________________________________________________
125 void AliMUONSegmentationV0::SetHit(Float_t xhit, Float_t yhit)
126 {
127     //
128     // Sets virtual hit position, needed for evaluating pad response 
129     // outside the tracking program 
130     fXhit=xhit;
131     fYhit=yhit;
132 }
133 //_______________________________________________________________________
134 void     AliMUONSegmentationV0::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
135 {
136   SetHit(xhit, yhit);
137 }
138 //_______________________________________________________________________
139
140
141 void AliMUONSegmentationV0::
142 SetPad(Int_t ix, Int_t iy)
143 {
144     //
145     // Sets virtual pad coordinates, needed for evaluating pad response 
146     // outside the tracking program 
147     GetPadC(ix,iy,fX,fY);
148 }
149 //____________________________________________________________________________________
150 void AliMUONSegmentationV0::FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
151 {
152 // Initialises iteration over pads for charge distribution algorithm
153 //
154     //
155     // Find the wire position (center of charge distribution)
156     Float_t x0a=GetAnod(xhit);
157     fXhit=x0a;
158     fYhit=yhit;
159     //
160     // and take fNsigma*sigma around this center
161     Float_t x01=x0a  - dx;
162     Float_t x02=x0a  + dx;
163     Float_t y01=yhit - dy;
164     Float_t y02=yhit + dy;
165     //
166     // find the pads over which the charge distributes
167     GetPadI(x01,y01,fIxmin,fIymin);
168     GetPadI(x02,y02,fIxmax,fIymax);    
169     // 
170     // Set current pad to lower left corner
171     fIx=fIxmin;
172     fIy=fIymin;
173     GetPadC(fIx,fIy,fX,fY);
174 }
175 //________________________________________________________________________
176 void AliMUONSegmentationV0::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/, Float_t dx, Float_t dy)
177         {FirstPad(xhit, yhit, dx, dy);}
178
179
180 void AliMUONSegmentationV0::NextPad()
181 {
182   // Stepper for the iteration over pads   
183   // 
184   // Comments and Critics:
185   // Boundary crossing at x=0 or y=0 not correctly handled !
186   // Step to next pad in the integration region
187     if (fIx != fIxmax) {
188         if (fIx==-1) fIx++;
189         fIx++;
190     } else if (fIy != fIymax) {
191         fIx=fIxmin;
192         if (fIy==-1) fIy++;
193         fIy++;
194     } else {
195         printf("\n Error: Stepping outside integration region\n ");
196     }
197     GetPadC(fIx,fIy,fX,fY);
198 }
199
200 Int_t AliMUONSegmentationV0::MorePads()
201 {
202 // Stopping condition for the iterator over pads
203 //
204 // Are there more pads in the integration region ? 
205
206     if (fIx == fIxmax && fIy == fIymax) {
207         return 0;
208     } else {
209         return 1;
210         
211     }
212 }
213
214 void AliMUONSegmentationV0::SigGenInit(Float_t x,Float_t y,Float_t /*z*/)
215 {
216 //
217 //  Initialises pad and wire position during stepping
218     fXt =x;
219     fYt =y;
220     GetPadI(x,y,fIxt,fIyt);
221     fIwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
222 }
223  
224 Int_t AliMUONSegmentationV0::SigGenCond(Float_t x,Float_t y,Float_t /*z*/) 
225 {
226 //  Signal generation condition during stepping 
227 //  0: don't generate signal
228 //  1: generate signal 
229 //  Comments and critics: 
230
231 //  Crossing of pad boundary and mid plane between neighbouring wires is checked.
232 //  To correctly simulate the dependence of the spatial resolution on the angle 
233 //  of incidence signal must be generated for constant steps on 
234 //  the projection of the trajectory along the anode wire.
235
236 //
237 //  Signal will be generated if particle crosses pad boundary or
238 //  boundary between two wires. 
239     Int_t ixt, iyt;
240     GetPadI(x,y,ixt,iyt);
241     Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
242     if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
243         return 1;
244     } else {
245         return 0;
246     }
247 }
248 void AliMUONSegmentationV0::
249 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
250 {
251 //  Returns integration limits for current pad
252 //
253     x1=fXhit-fX-fDpx/2.;
254     x2=x1+fDpx;
255     y1=fYhit-fY-fDpy/2.;
256     y2=y1+fDpy;    
257 }
258
259 void AliMUONSegmentationV0::
260 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10]) 
261 {
262 // Returns list of next neighbours for given Pad (iX, iY)
263 //
264 // Comments and critics
265 //     "Diagonal" neighbours are not passed
266 //      Is this ok when we search for local maxima ??
267 //      No test whether neighbours have valid indices id performed
268     *Nlist=4;
269     Xlist[0]=Xlist[1]=iX;
270     Xlist[2]=iX-1;
271     Xlist[3]=iX+1;
272     Ylist[0]=iY-1;
273     Ylist[1]=iY+1;
274     Ylist[2]=Ylist[3]=iY;
275 }
276
277 Float_t AliMUONSegmentationV0::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y
278                                                   , Int_t * /*dummy*/)
279 {
280 // Returns the square of the distance between 1 pad
281 // labelled by its Channel numbers and a coordinate
282
283   Float_t x,y;
284   GetPadC(iX,iY,x,y);
285   return (x-X)*(x-X) + (y-Y)*(y-Y);
286 }
287
288
289 void  AliMUONSegmentationV0::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y) const
290 {
291 // Returns test point on the pad plane.
292 // Used during determination of the segmoid correction of the COG-method
293     n=1;
294     x[0]=(fRmax+fRmin)/2/TMath::Sqrt(2.);
295     y[0]=x[0];
296 }
297
298 void AliMUONSegmentationV0::Draw(const char *) const
299 {
300 // Draws the segmentation zones
301 //
302     TArc *circle;
303     Float_t scale=0.95/fRmax/2.;
304     
305
306     circle = new TArc(0.5,0.5,fRmax*scale,0.,360.);
307     circle->SetFillColor(2);
308     circle->Draw();
309
310     circle = new TArc(0.5,0.5,fRmin*scale,0.,360.);
311     circle->SetFillColor(1);
312     circle->Draw();
313 }
314
315 AliMUONSegmentationV0& AliMUONSegmentationV0::operator =(const AliMUONSegmentationV0 & /*rhs*/)
316 {
317 // Dummy assignment operator
318     return *this;
319 }