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