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