1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
20 #include "AliMUONSegResV0.h"
24 #include "AliMUONchamber.h"
25 ClassImp(AliMUONsegmentationV0)
26 void AliMUONsegmentationV0::Init(AliMUONchamber* Chamber)
28 fNpx=(Int_t) (Chamber->ROuter()/fDpx+1);
29 fNpy=(Int_t) (Chamber->ROuter()/fDpy+1);
30 fRmin=Chamber->RInner();
31 fRmax=Chamber->ROuter();
37 Float_t AliMUONsegmentationV0::GetAnod(Float_t xhit)
39 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
43 void AliMUONsegmentationV0::SetPADSIZ(Float_t p1, Float_t p2)
48 void AliMUONsegmentationV0::
49 GetPadIxy(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
51 // returns pad coordinates (ix,iy) for given real coordinates (x,y)
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;
60 void AliMUONsegmentationV0::
61 GetPadCxy(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
63 // returns real coordinates (x,y) for given pad coordinates (ix,iy)
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.;
69 void AliMUONsegmentationV0::
70 SetHit(Float_t xhit, Float_t yhit)
73 // Find the wire position (center of charge distribution)
74 // Float_t x0a=GetAnod(xhit);
79 void AliMUONsegmentationV0::
80 SetPad(Int_t ix, Int_t iy)
82 GetPadCxy(ix,iy,fx,fy);
85 void AliMUONsegmentationV0::
86 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
89 // Find the wire position (center of charge distribution)
90 Float_t x0a=GetAnod(xhit);
94 // and take fNsigma*sigma around this center
97 Float_t y01=yhit - dy;
98 Float_t y02=yhit + dy;
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);
109 // Set current pad to lower left corner
112 GetPadCxy(fix,fiy,fx,fy);
115 void AliMUONsegmentationV0::NextPad()
118 // Step to next pad in integration region
122 } else if (fiy != fiymax) {
127 printf("\n Error: Stepping outside integration region\n ");
129 GetPadCxy(fix,fiy,fx,fy);
132 Int_t AliMUONsegmentationV0::MorePads()
134 // Are there more pads in the integration region
136 if (fix == fixmax && fiy == fiymax) {
144 void AliMUONsegmentationV0::SigGenInit(Float_t x,Float_t y,Float_t)
147 // Initialises pad and wire position during stepping
150 GetPadIxy(x,y,fixt,fiyt);
151 fiwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
154 Int_t AliMUONsegmentationV0::SigGenCond(Float_t x,Float_t y,Float_t)
157 // Signal will be generated if particle crosses pad boundary or
158 // boundary between two wires.
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)) {
168 void AliMUONsegmentationV0::
169 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
171 // x1=GetAnod(fxt)-fx-fDpx/2.;
178 void AliMUONsegmentationV0::
179 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[7], Int_t Ylist[7])
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;
186 Xlist[0]=Xlist[1]=iX;
191 Ylist[2]=Ylist[3]=iY;
207 Float_t AliMUONsegmentationV0::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y
209 // Returns the square of the distance between 1 pad
210 // labelled by its Channel numbers and a coordinate
213 GetPadCxy(iX,iY,x,y);
214 return (x-X)*(x-X) + (y-Y)*(y-Y);
217 void AliMUONsegmentationV0::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y)
220 x[0]=(fRmax+fRmin)/2/TMath::Sqrt(2.);
224 void AliMUONsegmentationV0::Draw(Option_t *)
227 Float_t scale=0.95/fRmax/2.;
230 circle = new TArc(0.5,0.5,fRmax*scale,0.,360.);
231 circle->SetFillColor(2);
234 circle = new TArc(0.5,0.5,fRmin*scale,0.,360.);
235 circle->SetFillColor(1);
241 //___________________________________________
242 ClassImp(AliMUONresponseV0)
243 Float_t AliMUONresponseV0::IntPH(Float_t eloss)
245 // Get number of electrons and return charge
248 nel= Int_t(eloss*1.e9/32.);
251 for (Int_t i=1;i<=nel;i++) {
252 charge -= fChargeSlope*TMath::Log(gRandom->Rndm());
256 // -------------------------------------------
258 Float_t AliMUONresponseV0::IntXY(AliMUONsegmentation * segmentation)
261 const Float_t invpitch = 1/fPitch;
263 // Integration limits defined by segmentation model
265 Float_t xi1, xi2, yi1, yi2;
266 segmentation->IntegrationLimits(xi1,xi2,yi1,yi2);
272 // The Mathieson function
273 Double_t ux1=fSqrtKx3*TMath::TanH(fKx2*xi1);
274 Double_t ux2=fSqrtKx3*TMath::TanH(fKx2*xi2);
276 Double_t uy1=fSqrtKy3*TMath::TanH(fKy2*yi1);
277 Double_t uy2=fSqrtKy3*TMath::TanH(fKy2*yi2);
280 return Float_t(4.*fKx4*(TMath::ATan(ux2)-TMath::ATan(ux1))*
281 fKy4*(TMath::ATan(uy2)-TMath::ATan(uy1)));