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