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 /////////////////////////////////////////////////////
21 // Segmentation and Response classes version 01 //
22 /////////////////////////////////////////////////////
29 #include "AliMUONSegResV01.h"
34 //___________________________________________
35 ClassImp(AliMUONsegmentationV01)
37 Float_t AliMUONsegmentationV01::Dpx(Int_t isec)
42 Float_t AliMUONsegmentationV01::Dpy(Int_t )
47 AliMUONsegmentationV01::AliMUONsegmentationV01()
53 fRSec[0]=fRSec[1]=fRSec[2]=fRSec[3]=0;
54 fNDiv[0]=fNDiv[1]=fNDiv[2]=fNDiv[3]=0;
55 fDpxD[0]=fDpxD[1]=fDpxD[2]=fDpxD[3]=0;
56 fCorr = new TObjArray(3);
62 void AliMUONsegmentationV01::SetSegRadii(Float_t r[4])
64 for (Int_t i=0; i<4; i++) {
66 //printf("\n R %d %f \n",i,fRSec[i]);
72 void AliMUONsegmentationV01::SetPadDivision(Int_t ndiv[4])
75 // Defines the pad size perp. to the anode wire (y) for different sectors.
77 for (Int_t i=0; i<4; i++) {
79 //printf("\n Ndiv %d %d \n",i,fNDiv[i]);
85 void AliMUONsegmentationV01::Init(AliMUONchamber* )
88 // Fill the arrays fCx (x-contour) and fNpxS (ix-contour) for each sector
89 // These arrays help in converting from real to pad co-ordinates and
93 //printf("\n Initialise segmentation v01 -- test !!!!!!!!!!!!!! \n");
94 fNpy=Int_t(fRSec[fNsec-1]/fDpy)+1;
98 for (Int_t i=fNsec-2; i>=0; i--){
99 fDpxD[i]=fDpxD[fNsec-1]/fNDiv[i];
100 //printf("\n test ---dx %d %f \n",i,fDpxD[i]);
104 // fill the arrays defining the pad segmentation boundaries
109 // loop over sections
110 for(isec=0; isec<fNsec; isec++) {
112 // loop over pads along the aode wires
113 for (Int_t iy=1; iy<=fNpy; iy++) {
115 Float_t x=iy*fDpy-fDpy/2;
116 if (x > fRSec[isec]) {
120 ry=TMath::Sqrt(fRSec[isec]*fRSec[isec]-x*x);
122 dnx= Int_t((ry-fCx[isec-1][iy])/fDpxD[isec]);
123 if (isec < fNsec-1) {
124 if (TMath::Odd((Long_t)dnx)) dnx++;
126 fNpxS[isec][iy]=fNpxS[isec-1][iy]+dnx;
127 fCx[isec][iy]=fCx[isec-1][iy]+dnx*fDpxD[isec];
128 } else if (isec == 1) {
129 dnx= Int_t((ry-fCx[isec-1][iy])/fDpxD[isec]);
130 fNpxS[isec][iy]=fNpxS[isec-1][iy]+dnx;
131 add=4 - (fNpxS[isec][iy])%4;
132 if (add < 4) fNpxS[isec][iy]+=add;
133 dnx=fNpxS[isec][iy]-fNpxS[isec-1][iy];
134 fCx[isec][iy]=fCx[isec-1][iy]+dnx*fDpxD[isec];
136 dnx=Int_t(ry/fDpxD[isec]);
138 fCx[isec][iy]=dnx*fDpxD[isec];
144 // for debugging only
146 //printf("segmentationv01 - I was here ! \n");
149 Int_t AliMUONsegmentationV01::Sector(Int_t ix, Int_t iy)
151 Int_t absix=TMath::Abs(ix);
152 Int_t absiy=TMath::Abs(iy);
154 for (Int_t i=0; i<fNsec; i++) {
155 if (absix<=fNpxS[i][absiy]){
163 void AliMUONsegmentationV01::
164 GetPadIxy(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
166 // returns pad coordinates (ix,iy) for given real coordinates (x,y)
168 iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy)-1;
169 if (iy > fNpy) iy= fNpy;
170 if (iy < -fNpy) iy=-fNpy;
174 Float_t absx=TMath::Abs(x);
175 Int_t absiy=TMath::Abs(iy);
176 for (Int_t i=0; i < fNsec; i++) {
177 if (absx <= fCx[i][absiy]) {
183 ix= Int_t((absx-fCx[isec-1][absiy])/fDpxD[isec])
184 +fNpxS[isec-1][absiy]+1;
185 } else if (isec == 0) {
186 ix= Int_t(absx/fDpxD[isec])+1;
188 ix=fNpxS[fNsec-1][absiy]+1;
190 // printf("\n something %d %d \n",isec,absiy);
195 void AliMUONsegmentationV01::
196 GetPadCxy(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
198 // returns real coordinates (x,y) for given pad coordinates (ix,iy)
200 y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)+fDpy/2.;
203 Int_t isec=AliMUONsegmentationV01::Sector(ix,iy);
205 Int_t absix=TMath::Abs(ix);
206 Int_t absiy=TMath::Abs(iy);
208 x=fCx[isec-1][absiy]+(absix-fNpxS[isec-1][absiy])*fDpxD[isec];
209 x=(ix>0) ? x-fDpxD[isec]/2 : -x+fDpxD[isec]/2;
215 void AliMUONsegmentationV01::
216 SetPad(Int_t ix, Int_t iy)
218 GetPadCxy(ix,iy,fx,fy);
219 fSector=Sector(ix,iy);
223 void AliMUONsegmentationV01::
224 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
227 // Find the wire position (center of charge distribution)
228 Float_t x0a=GetAnod(xhit);
233 // and take fNsigma*sigma around this center
234 Float_t x01=x0a - dx;
235 Float_t x02=x0a + dx;
236 Float_t y01=yhit - dy;
237 Float_t y02=yhit + dy;
239 // find the pads over which the charge distributes
240 GetPadIxy(x01,y01,fixmin,fiymin);
241 GetPadIxy(x02,y02,fixmax,fiymax);
248 // Set current pad to lower left corner
249 if (fixmax < fixmin) fixmax=fixmin;
250 if (fiymax < fiymin) fiymax=fiymin;
253 GetPadCxy(fix,fiy,fx,fy);
257 void AliMUONsegmentationV01::NextPad()
260 // Step to next pad in integration region
264 // step from left to right
265 if (fx < fxmax && fx != 0) {
269 } else if (fiy != fiymax) {
272 // get y-position of next row (yc), xc not used here
273 GetPadCxy(fix,fiy,xc,yc);
274 // get x-pad coordiante for 1 pad in row (fix)
275 GetPadIxy(fxmin,yc,fix,iyc);
277 printf("\n Error: Stepping outside integration region\n ");
279 GetPadCxy(fix,fiy,fx,fy);
280 fSector=Sector(fix,fiy);
282 (fSector ==-1 || fSector==0 ||
283 TMath::Abs(fx)<1.5 || TMath::Abs(fy)<1.5))
286 // printf("\n this pad %f %f %d %d \n",fx,fy,fix,fiy);
290 Int_t AliMUONsegmentationV01::MorePads()
292 // Are there more pads in the integration region
294 if ((fx >= fxmax && fiy >= fiymax) || fy==0) {
301 void AliMUONsegmentationV01::
302 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
304 x1=fxhit-fx-Dpx(fSector)/2.;
306 y1=fyhit-fy-Dpy(fSector)/2.;
310 void AliMUONsegmentationV01::
311 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
313 const Float_t epsilon=fDpy/1000;
316 Int_t ixx, iyy, isec1;
318 Int_t isec0=AliMUONsegmentationV01::Sector(iX,iY);
330 AliMUONsegmentationV01::GetPadCxy(iX,iY,x,y);
331 AliMUONsegmentationV01::GetPadIxy(x+epsilon,y+fDpy,ixx,iyy);
334 isec1=AliMUONsegmentationV01::Sector(ixx,iyy);
337 // no sector boundary crossing
343 } else if (isec1 < isec0) {
344 // finer segmentation
354 // coarser segmenation
356 if (TMath::Odd(iX-fNpxS[isec1-1][iY+1])) {
366 AliMUONsegmentationV01::GetPadCxy(iX,iY,x,y);
367 AliMUONsegmentationV01::GetPadIxy(x+epsilon,y-fDpy,ixx,iyy);
370 isec1=AliMUONsegmentationV01::Sector(ixx,iyy);
373 // no sector boundary crossing
379 } else if (isec1 < isec0) {
380 // finer segmentation
390 // coarser segmentation
392 if (TMath::Odd(iX-fNpxS[isec1-1][iY-1])) {
404 void AliMUONsegmentationV01::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y)
407 x[0]=(fRSec[0]+fRSec[1])/2/TMath::Sqrt(2.);
409 x[1]=(fRSec[1]+fRSec[2])/2/TMath::Sqrt(2.);
411 x[2]=(fRSec[2]+fRSec[3])/2/TMath::Sqrt(2.);
415 void AliMUONsegmentationV01::Draw(Option_t *)
419 Float_t dx=0.95/fCx[3][1]/2;
420 Float_t dy=0.95/(Float_t(Npy()))/2;
425 for (Int_t iy=1; iy<Npy(); iy++)
427 for (Int_t isec=0; isec<4; isec++) {
432 x0=fCx[isec-1][iy]*dx;
437 box=new TBox(x0+xc,y0+yc,x1+xc,y1+yc);
438 box->SetFillColor(isec+1);
441 box=new TBox(-x1+xc,y0+yc,-x0+xc,y1+yc);
442 box->SetFillColor(isec+1);
445 box=new TBox(x0+xc,-y1+yc,x1+xc,-y0+yc);
446 box->SetFillColor(isec+1);
449 box=new TBox(-x1+xc,-y1+yc,-x0+xc,-y0+yc);
450 box->SetFillColor(isec+1);
455 void AliMUONsegmentationV01::SetCorrFunc(Int_t isec, TF1* func)
461 TF1* AliMUONsegmentationV01::CorrFunc(Int_t isec)
463 return (TF1*) (*fCorr)[isec];