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