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 **************************************************************************/
18 Revision 1.3 1999/09/29 09:24:23 fca
19 Introduction of the Copyright and cvs Log
23 #include "AliMUONSegResV0.h"
27 #include "AliMUONchamber.h"
28 ClassImp(AliMUONsegmentationV0)
29 void AliMUONsegmentationV0::Init(AliMUONchamber* Chamber)
31 fNpx=(Int_t) (Chamber->ROuter()/fDpx+1);
32 fNpy=(Int_t) (Chamber->ROuter()/fDpy+1);
33 fRmin=Chamber->RInner();
34 fRmax=Chamber->ROuter();
40 Float_t AliMUONsegmentationV0::GetAnod(Float_t xhit)
42 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
46 void AliMUONsegmentationV0::SetPADSIZ(Float_t p1, Float_t p2)
51 void AliMUONsegmentationV0::
52 GetPadIxy(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
54 // returns pad coordinates (ix,iy) for given real coordinates (x,y)
56 ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx)-1;
57 iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy)-1;
58 if (iy > fNpy) iy= fNpy;
59 if (iy < -fNpy) iy=-fNpy;
60 if (ix > fNpx) ix= fNpx;
61 if (ix < -fNpx) ix=-fNpx;
63 void AliMUONsegmentationV0::
64 GetPadCxy(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
66 // returns real coordinates (x,y) for given pad coordinates (ix,iy)
68 x = (ix>0) ? Float_t(ix*fDpx)-fDpx/2. : Float_t(ix*fDpx)+fDpx/2.;
69 y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)+fDpy/2.;
72 void AliMUONsegmentationV0::
73 SetHit(Float_t xhit, Float_t yhit)
76 // Find the wire position (center of charge distribution)
77 // Float_t x0a=GetAnod(xhit);
82 void AliMUONsegmentationV0::
83 SetPad(Int_t ix, Int_t iy)
85 GetPadCxy(ix,iy,fx,fy);
88 void AliMUONsegmentationV0::
89 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
92 // Find the wire position (center of charge distribution)
93 Float_t x0a=GetAnod(xhit);
97 // and take fNsigma*sigma around this center
100 Float_t y01=yhit - dy;
101 Float_t y02=yhit + dy;
103 // find the pads over which the charge distributes
104 GetPadIxy(x01,y01,fixmin,fiymin);
105 GetPadIxy(x02,y02,fixmax,fiymax);
106 // printf("\n %f %f %d %d \n",x02,y02,fixmax,fiymax);
107 // printf("\n FirstPad called %f %f \n", fDpx, fDpy);
108 // printf("\n Hit Position %f %f \n",xhit,yhit);
109 // printf("\n Integration limits: %i %i %i %i",fixmin,fixmax,fiymin,fiymax);
110 // printf("\n Integration limits: %f %f %f %f \n",x01,x02,y01,y02);
112 // Set current pad to lower left corner
115 GetPadCxy(fix,fiy,fx,fy);
118 void AliMUONsegmentationV0::NextPad()
121 // Step to next pad in integration region
125 } else if (fiy != fiymax) {
130 printf("\n Error: Stepping outside integration region\n ");
132 GetPadCxy(fix,fiy,fx,fy);
135 Int_t AliMUONsegmentationV0::MorePads()
137 // Are there more pads in the integration region
139 if (fix == fixmax && fiy == fiymax) {
147 void AliMUONsegmentationV0::SigGenInit(Float_t x,Float_t y,Float_t)
150 // Initialises pad and wire position during stepping
153 GetPadIxy(x,y,fixt,fiyt);
154 fiwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
157 Int_t AliMUONsegmentationV0::SigGenCond(Float_t x,Float_t y,Float_t)
160 // Signal will be generated if particle crosses pad boundary or
161 // boundary between two wires.
163 GetPadIxy(x,y,ixt,iyt);
164 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
165 if ((ixt != fixt) || (iyt !=fiyt) || (iwt != fiwt)) {
171 void AliMUONsegmentationV0::
172 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
174 // x1=GetAnod(fxt)-fx-fDpx/2.;
181 void AliMUONsegmentationV0::
182 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
185 *Nlist=4;Xlist[0]=Xlist[1]=iX;Xlist[2]=iX-1;Xlist[3]=iX+1;
186 Ylist[0]=iY-1;Ylist[1]=iY+1;Ylist[2]=Ylist[3]=iY;
189 Xlist[0]=Xlist[1]=iX;
194 Ylist[2]=Ylist[3]=iY;
210 Float_t AliMUONsegmentationV0::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y
212 // Returns the square of the distance between 1 pad
213 // labelled by its Channel numbers and a coordinate
216 GetPadCxy(iX,iY,x,y);
217 return (x-X)*(x-X) + (y-Y)*(y-Y);
220 void AliMUONsegmentationV0::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y)
223 x[0]=(fRmax+fRmin)/2/TMath::Sqrt(2.);
227 void AliMUONsegmentationV0::Draw(Option_t *)
230 Float_t scale=0.95/fRmax/2.;
233 circle = new TArc(0.5,0.5,fRmax*scale,0.,360.);
234 circle->SetFillColor(2);
237 circle = new TArc(0.5,0.5,fRmin*scale,0.,360.);
238 circle->SetFillColor(1);
244 //___________________________________________
245 ClassImp(AliMUONresponseV0)
246 Float_t AliMUONresponseV0::IntPH(Float_t eloss)
248 // Get number of electrons and return charge
251 nel= Int_t(eloss*1.e9/32.);
254 for (Int_t i=1;i<=nel;i++) {
255 charge -= fChargeSlope*TMath::Log(gRandom->Rndm());
259 // -------------------------------------------
261 Float_t AliMUONresponseV0::IntXY(AliMUONsegmentation * segmentation)
264 const Float_t invpitch = 1/fPitch;
266 // Integration limits defined by segmentation model
268 Float_t xi1, xi2, yi1, yi2;
269 segmentation->IntegrationLimits(xi1,xi2,yi1,yi2);
275 // The Mathieson function
276 Double_t ux1=fSqrtKx3*TMath::TanH(fKx2*xi1);
277 Double_t ux2=fSqrtKx3*TMath::TanH(fKx2*xi2);
279 Double_t uy1=fSqrtKy3*TMath::TanH(fKy2*yi1);
280 Double_t uy2=fSqrtKy3*TMath::TanH(fKy2*yi2);
283 return Float_t(4.*fKx4*(TMath::ATan(ux2)-TMath::ATan(ux1))*
284 fKy4*(TMath::ATan(uy2)-TMath::ATan(uy1)));