]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSegResV0.cxx
Introduction of the Copyright and cvs Log
[u/mrichter/AliRoot.git] / MUON / AliMUONSegResV0.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 /*
17 $Log$
18 */
19
20 #include "AliMUONSegResV0.h"
21 #include "TMath.h"
22 #include "TRandom.h"
23 #include "TArc.h"
24 #include "AliMUONchamber.h"
25 ClassImp(AliMUONsegmentationV0)
26     void AliMUONsegmentationV0::Init(AliMUONchamber* Chamber)
27 {
28     fNpx=(Int_t) (Chamber->ROuter()/fDpx+1);
29     fNpy=(Int_t) (Chamber->ROuter()/fDpy+1);
30     fRmin=Chamber->RInner();
31     fRmax=Chamber->ROuter();    
32     fCorr=0;
33     
34 }
35
36
37 Float_t AliMUONsegmentationV0::GetAnod(Float_t xhit)
38 {
39     Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
40     return fWireD*wire;
41 }
42
43 void AliMUONsegmentationV0::SetPADSIZ(Float_t p1, Float_t p2)
44 {
45     fDpx=p1;
46     fDpy=p2;
47 }
48 void AliMUONsegmentationV0::
49     GetPadIxy(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
50 {
51 //  returns pad coordinates (ix,iy) for given real coordinates (x,y)
52 //
53     ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx)-1;
54     iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy)-1;
55     if (iy >  fNpy) iy= fNpy;
56     if (iy < -fNpy) iy=-fNpy;
57     if (ix >  fNpx) ix= fNpx;
58     if (ix < -fNpx) ix=-fNpx;
59 }
60 void AliMUONsegmentationV0::
61 GetPadCxy(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
62 {
63 //  returns real coordinates (x,y) for given pad coordinates (ix,iy)
64 //
65     x = (ix>0) ? Float_t(ix*fDpx)-fDpx/2. : Float_t(ix*fDpx)+fDpx/2.;
66     y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)+fDpy/2.;
67 }
68
69 void AliMUONsegmentationV0::
70 SetHit(Float_t xhit, Float_t yhit)
71 {
72     //
73     // Find the wire position (center of charge distribution)
74 //    Float_t x0a=GetAnod(xhit);
75     fxhit=xhit;
76     fyhit=yhit;
77 }
78
79 void AliMUONsegmentationV0::
80 SetPad(Int_t ix, Int_t iy)
81 {
82     GetPadCxy(ix,iy,fx,fy);
83 }
84
85 void AliMUONsegmentationV0::
86 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
87 {
88     //
89     // Find the wire position (center of charge distribution)
90     Float_t x0a=GetAnod(xhit);
91     fxhit=x0a;
92     fyhit=yhit;
93     //
94     // and take fNsigma*sigma around this center
95     Float_t x01=x0a  - dx;
96     Float_t x02=x0a  + dx;
97     Float_t y01=yhit - dy;
98     Float_t y02=yhit + dy;
99     //
100     // find the pads over which the charge distributes
101     GetPadIxy(x01,y01,fixmin,fiymin);
102     GetPadIxy(x02,y02,fixmax,fiymax);    
103 //    printf("\n %f %f %d %d \n",x02,y02,fixmax,fiymax);
104 //    printf("\n FirstPad called %f %f \n", fDpx, fDpy);
105 //    printf("\n Hit Position %f %f \n",xhit,yhit);
106 //    printf("\n Integration limits: %i %i %i %i",fixmin,fixmax,fiymin,fiymax);
107 //    printf("\n Integration limits: %f %f %f %f \n",x01,x02,y01,y02);
108     // 
109     // Set current pad to lower left corner
110     fix=fixmin;
111     fiy=fiymin;
112     GetPadCxy(fix,fiy,fx,fy);
113 }
114
115 void AliMUONsegmentationV0::NextPad()
116 {
117   // 
118   // Step to next pad in integration region
119     if (fix != fixmax) {
120         if (fix==-1) fix++;
121         fix++;
122     } else if (fiy != fiymax) {
123         fix=fixmin;
124         if (fiy==-1) fiy++;
125         fiy++;
126     } else {
127         printf("\n Error: Stepping outside integration region\n ");
128     }
129     GetPadCxy(fix,fiy,fx,fy);
130 }
131
132 Int_t AliMUONsegmentationV0::MorePads()
133 //
134 // Are there more pads in the integration region
135 {
136     if (fix == fixmax && fiy == fiymax) {
137         return 0;
138     } else {
139         return 1;
140         
141     }
142 }
143
144 void AliMUONsegmentationV0::SigGenInit(Float_t x,Float_t y,Float_t)
145 {
146 //
147 //  Initialises pad and wire position during stepping
148     fxt =x;
149     fyt =y;
150     GetPadIxy(x,y,fixt,fiyt);
151     fiwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
152 }
153
154 Int_t AliMUONsegmentationV0::SigGenCond(Float_t x,Float_t y,Float_t)
155 {
156 //
157 //  Signal will be generated if particle crosses pad boundary or
158 //  boundary between two wires. 
159     Int_t ixt, iyt;
160     GetPadIxy(x,y,ixt,iyt);
161     Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
162     if ((ixt != fixt) || (iyt !=fiyt) || (iwt != fiwt)) {
163         return 1;
164     } else {
165         return 0;
166     }
167 }
168 void AliMUONsegmentationV0::
169 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
170 {
171 //    x1=GetAnod(fxt)-fx-fDpx/2.;
172     x1=fxhit-fx-fDpx/2.;
173     x2=x1+fDpx;
174     y1=fyhit-fy-fDpy/2.;
175     y2=y1+fDpy;    
176 }
177
178 void AliMUONsegmentationV0::
179 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[7], Int_t Ylist[7])
180 {
181   /*
182     *Nlist=4;Xlist[0]=Xlist[1]=iX;Xlist[2]=iX-1;Xlist[3]=iX+1;
183     Ylist[0]=iY-1;Ylist[1]=iY+1;Ylist[2]=Ylist[3]=iY;
184   */
185     *Nlist=8;
186     Xlist[0]=Xlist[1]=iX;
187     Xlist[2]=iX-1;
188     Xlist[3]=iX+1;
189     Ylist[0]=iY-1;
190     Ylist[1]=iY+1;
191     Ylist[2]=Ylist[3]=iY;
192
193    // Diagonal elements
194     Xlist[4]=iX+1;
195     Ylist[4]=iY+1;
196
197     Xlist[5]=iX-1;
198     Ylist[5]=iY-1;
199
200     Xlist[6]=iX-1;
201     Ylist[6]=iY+1;
202
203     Xlist[7]=iX+1;
204     Ylist[7]=iY-1;
205 }
206
207 Float_t AliMUONsegmentationV0::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y
208 , Int_t *)
209 // Returns the square of the distance between 1 pad
210 // labelled by its Channel numbers and a coordinate
211 {
212   Float_t x,y;
213   GetPadCxy(iX,iY,x,y);
214   return (x-X)*(x-X) + (y-Y)*(y-Y);
215 }
216
217 void  AliMUONsegmentationV0::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y)
218 {
219     n=1;
220     x[0]=(fRmax+fRmin)/2/TMath::Sqrt(2.);
221     y[0]=x[0];
222 }
223
224 void AliMUONsegmentationV0::Draw(Option_t *)
225 {
226     TArc *circle;
227     Float_t scale=0.95/fRmax/2.;
228     
229
230     circle = new TArc(0.5,0.5,fRmax*scale,0.,360.);
231     circle->SetFillColor(2);
232     circle->Draw();
233
234     circle = new TArc(0.5,0.5,fRmin*scale,0.,360.);
235     circle->SetFillColor(1);
236     circle->Draw();
237 }
238
239
240
241 //___________________________________________
242 ClassImp(AliMUONresponseV0)     
243 Float_t AliMUONresponseV0::IntPH(Float_t eloss)
244 {
245   // Get number of electrons and return charge
246      
247   Int_t nel;
248   nel= Int_t(eloss*1.e9/32.);
249   Float_t charge=0;
250   if (nel == 0) nel=1;
251   for (Int_t i=1;i<=nel;i++) {
252     charge -= fChargeSlope*TMath::Log(gRandom->Rndm());    
253   }
254   return charge;
255 }
256 // -------------------------------------------
257
258 Float_t AliMUONresponseV0::IntXY(AliMUONsegmentation * segmentation)
259 {
260
261     const Float_t invpitch = 1/fPitch;
262 //
263 //  Integration limits defined by segmentation model
264 //  
265     Float_t xi1, xi2, yi1, yi2;
266     segmentation->IntegrationLimits(xi1,xi2,yi1,yi2);
267     xi1=xi1*invpitch;
268     xi2=xi2*invpitch;
269     yi1=yi1*invpitch;
270     yi2=yi2*invpitch;
271 //
272 // The Mathieson function 
273     Double_t ux1=fSqrtKx3*TMath::TanH(fKx2*xi1);
274     Double_t ux2=fSqrtKx3*TMath::TanH(fKx2*xi2);
275
276     Double_t uy1=fSqrtKy3*TMath::TanH(fKy2*yi1);
277     Double_t uy2=fSqrtKy3*TMath::TanH(fKy2*yi2);
278
279     
280     return Float_t(4.*fKx4*(TMath::ATan(ux2)-TMath::ATan(ux1))*
281                       fKy4*(TMath::ATan(uy2)-TMath::ATan(uy1)));
282 }
283
284
285
286
287
288
289
290
291