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