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