1 #include "AliMUONSegResV0.h"
5 #include "AliMUONchamber.h"
6 ClassImp(AliMUONsegmentationV0)
7 void AliMUONsegmentationV0::Init(AliMUONchamber* Chamber)
9 fNpx=(Int_t) (Chamber->ROuter()/fDpx+1);
10 fNpy=(Int_t) (Chamber->ROuter()/fDpy+1);
11 fRmin=Chamber->RInner();
12 fRmax=Chamber->ROuter();
18 Float_t AliMUONsegmentationV0::GetAnod(Float_t xhit)
20 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
24 void AliMUONsegmentationV0::SetPADSIZ(Float_t p1, Float_t p2)
29 void AliMUONsegmentationV0::
30 GetPadIxy(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
32 // returns pad coordinates (ix,iy) for given real coordinates (x,y)
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;
41 void AliMUONsegmentationV0::
42 GetPadCxy(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
44 // returns real coordinates (x,y) for given pad coordinates (ix,iy)
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.;
50 void AliMUONsegmentationV0::
51 SetHit(Float_t xhit, Float_t yhit)
54 // Find the wire position (center of charge distribution)
55 // Float_t x0a=GetAnod(xhit);
60 void AliMUONsegmentationV0::
61 SetPad(Int_t ix, Int_t iy)
63 GetPadCxy(ix,iy,fx,fy);
66 void AliMUONsegmentationV0::
67 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
70 // Find the wire position (center of charge distribution)
71 Float_t x0a=GetAnod(xhit);
75 // and take fNsigma*sigma around this center
78 Float_t y01=yhit - dy;
79 Float_t y02=yhit + dy;
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);
90 // Set current pad to lower left corner
93 GetPadCxy(fix,fiy,fx,fy);
96 void AliMUONsegmentationV0::NextPad()
99 // Step to next pad in integration region
103 } else if (fiy != fiymax) {
108 printf("\n Error: Stepping outside integration region\n ");
110 GetPadCxy(fix,fiy,fx,fy);
113 Int_t AliMUONsegmentationV0::MorePads()
115 // Are there more pads in the integration region
117 if (fix == fixmax && fiy == fiymax) {
125 void AliMUONsegmentationV0::SigGenInit(Float_t x,Float_t y,Float_t)
128 // Initialises pad and wire position during stepping
131 GetPadIxy(x,y,fixt,fiyt);
132 fiwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
135 Int_t AliMUONsegmentationV0::SigGenCond(Float_t x,Float_t y,Float_t)
138 // Signal will be generated if particle crosses pad boundary or
139 // boundary between two wires.
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)) {
149 void AliMUONsegmentationV0::
150 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
152 // x1=GetAnod(fxt)-fx-fDpx/2.;
159 void AliMUONsegmentationV0::
160 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[7], Int_t Ylist[7])
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;
167 Xlist[0]=Xlist[1]=iX;
172 Ylist[2]=Ylist[3]=iY;
188 Float_t AliMUONsegmentationV0::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y
190 // Returns the square of the distance between 1 pad
191 // labelled by its Channel numbers and a coordinate
194 GetPadCxy(iX,iY,x,y);
195 return (x-X)*(x-X) + (y-Y)*(y-Y);
198 void AliMUONsegmentationV0::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y)
201 x[0]=(fRmax+fRmin)/2/TMath::Sqrt(2.);
205 void AliMUONsegmentationV0::Draw(Option_t *)
208 Float_t scale=0.95/fRmax/2.;
211 circle = new TArc(0.5,0.5,fRmax*scale,0.,360.);
212 circle->SetFillColor(2);
215 circle = new TArc(0.5,0.5,fRmin*scale,0.,360.);
216 circle->SetFillColor(1);
222 //___________________________________________
223 ClassImp(AliMUONresponseV0)
224 Float_t AliMUONresponseV0::IntPH(Float_t eloss)
226 // Get number of electrons and return charge
229 nel= Int_t(eloss*1.e9/32.);
232 for (Int_t i=1;i<=nel;i++) {
233 charge -= fChargeSlope*TMath::Log(gRandom->Rndm());
237 // -------------------------------------------
239 Float_t AliMUONresponseV0::IntXY(AliMUONsegmentation * segmentation)
242 const Float_t invpitch = 1/fPitch;
244 // Integration limits defined by segmentation model
246 Float_t xi1, xi2, yi1, yi2;
247 segmentation->IntegrationLimits(xi1,xi2,yi1,yi2);
253 // The Mathieson function
254 Double_t ux1=fSqrtKx3*TMath::TanH(fKx2*xi1);
255 Double_t ux2=fSqrtKx3*TMath::TanH(fKx2*xi2);
257 Double_t uy1=fSqrtKy3*TMath::TanH(fKy2*yi1);
258 Double_t uy2=fSqrtKy3*TMath::TanH(fKy2*yi2);
261 return Float_t(4.*fKx4*(TMath::ATan(ux2)-TMath::ATan(ux1))*
262 fKy4*(TMath::ATan(uy2)-TMath::ATan(uy1)));