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 **************************************************************************/
16 /////////////////////////////////////////////////////
17 // Segmentation and Response classes version 01 //
18 /////////////////////////////////////////////////////
25 #include "AliMUONSegResV01.h"
30 //___________________________________________
31 ClassImp(AliMUONSegmentationV01)
34 AliMUONSegmentationV01::AliMUONSegmentationV01()
40 fRSec[0]=fRSec[1]=fRSec[2]=fRSec[3]=0;
41 fNDiv[0]=fNDiv[1]=fNDiv[2]=fNDiv[3]=0;
42 fDpxD[0]=fDpxD[1]=fDpxD[2]=fDpxD[3]=0;
43 fCorr = new TObjArray(3);
49 Float_t AliMUONSegmentationV01::Dpx(Int_t isec)
52 // Returns x-pad size for given sector isec
56 Float_t AliMUONSegmentationV01::Dpy(Int_t isec)
59 // Returns y-pad size for given sector isec
63 void AliMUONSegmentationV01::SetSegRadii(Float_t r[4])
66 // Set the radii of the segmentation zones
67 for (Int_t i=0; i<4; i++) {
69 printf("\n R %d %f \n",i,fRSec[i]);
75 void AliMUONSegmentationV01::SetPadDivision(Int_t ndiv[4])
78 // Defines the pad size perp. to the anode wire (y) for different sectors.
79 // Pad sizes are defined as integral fractions ndiv of a basis pad size
82 for (Int_t i=0; i<4; i++) {
84 printf("\n Ndiv %d %d \n",i,fNDiv[i]);
90 void AliMUONSegmentationV01::Init(AliMUONChamber* Chamber)
93 // Fill the arrays fCx (x-contour) and fNpxS (ix-contour) for each sector
94 // These arrays help in converting from real to pad co-ordinates and
96 // This version approximates concentric segmentation zones
99 printf("\n Initialise segmentation v01 -- test !!!!!!!!!!!!!! \n");
100 fNpy=Int_t(fRSec[fNsec-1]/fDpy)+1;
104 for (Int_t i=fNsec-2; i>=0; i--){
105 fDpxD[i]=fDpxD[fNsec-1]/fNDiv[i];
106 printf("\n test ---dx %d %f \n",i,fDpxD[i]);
110 // fill the arrays defining the pad segmentation boundaries
115 // loop over sections
116 for(isec=0; isec<fNsec; isec++) {
118 // loop over pads along the aode wires
119 for (Int_t iy=1; iy<=fNpy; iy++) {
121 Float_t x=iy*fDpy-fDpy/2;
122 if (x > fRSec[isec]) {
126 ry=TMath::Sqrt(fRSec[isec]*fRSec[isec]-x*x);
128 dnx= Int_t((ry-fCx[isec-1][iy])/fDpxD[isec]);
129 if (isec < fNsec-1) {
130 if (TMath::Odd((Long_t)dnx)) dnx++;
132 fNpxS[isec][iy]=fNpxS[isec-1][iy]+dnx;
133 fCx[isec][iy]=fCx[isec-1][iy]+dnx*fDpxD[isec];
134 } else if (isec == 1) {
135 dnx= Int_t((ry-fCx[isec-1][iy])/fDpxD[isec]);
136 fNpxS[isec][iy]=fNpxS[isec-1][iy]+dnx;
137 add=4 - (fNpxS[isec][iy])%4;
138 if (add < 4) fNpxS[isec][iy]+=add;
139 dnx=fNpxS[isec][iy]-fNpxS[isec-1][iy];
140 fCx[isec][iy]=fCx[isec-1][iy]+dnx*fDpxD[isec];
142 dnx=Int_t(ry/fDpxD[isec]);
144 fCx[isec][iy]=dnx*fDpxD[isec];
151 Int_t AliMUONSegmentationV01::Sector(Int_t ix, Int_t iy)
153 // Returns sector number for given pad position
155 Int_t absix=TMath::Abs(ix);
156 Int_t absiy=TMath::Abs(iy);
158 for (Int_t i=0; i<fNsec; i++) {
159 if (absix<=fNpxS[i][absiy]){
167 void AliMUONSegmentationV01::
168 GetPadIxy(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
170 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
172 iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy)-1;
173 if (iy > fNpy) iy= fNpy;
174 if (iy < -fNpy) iy=-fNpy;
178 Float_t absx=TMath::Abs(x);
179 Int_t absiy=TMath::Abs(iy);
180 for (Int_t i=0; i < fNsec; i++) {
181 if (absx <= fCx[i][absiy]) {
187 ix= Int_t((absx-fCx[isec-1][absiy])/fDpxD[isec])
188 +fNpxS[isec-1][absiy]+1;
189 } else if (isec == 0) {
190 ix= Int_t(absx/fDpxD[isec])+1;
192 ix=fNpxS[fNsec-1][absiy]+1;
197 void AliMUONSegmentationV01::
198 GetPadCxy(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
200 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
202 y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)+fDpy/2.;
205 Int_t isec=AliMUONSegmentationV01::Sector(ix,iy);
207 Int_t absix=TMath::Abs(ix);
208 Int_t absiy=TMath::Abs(iy);
210 x=fCx[isec-1][absiy]+(absix-fNpxS[isec-1][absiy])*fDpxD[isec];
211 x=(ix>0) ? x-fDpxD[isec]/2 : -x+fDpxD[isec]/2;
217 void AliMUONSegmentationV01::
218 SetPad(Int_t ix, Int_t iy)
221 // Sets virtual pad coordinates, needed for evaluating pad response
222 // outside the tracking program
223 GetPadCxy(ix,iy,fx,fy);
224 fSector=Sector(ix,iy);
228 void AliMUONSegmentationV01::
229 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
231 // Initialises iteration over pads for charge distribution algorithm
234 // Find the wire position (center of charge distribution)
235 Float_t x0a=GetAnod(xhit);
240 // and take fNsigma*sigma around this center
241 Float_t x01=x0a - dx;
242 Float_t x02=x0a + dx;
243 Float_t y01=yhit - dy;
244 Float_t y02=yhit + dy;
246 // find the pads over which the charge distributes
247 GetPadIxy(x01,y01,fixmin,fiymin);
248 GetPadIxy(x02,y02,fixmax,fiymax);
255 // Set current pad to lower left corner
256 if (fixmax < fixmin) fixmax=fixmin;
257 if (fiymax < fiymin) fiymax=fiymin;
260 GetPadCxy(fix,fiy,fx,fy);
264 void AliMUONSegmentationV01::NextPad()
266 // Stepper for the iteration over pads
268 // Step to next pad in the integration region
270 // Step to next pad in integration region
274 // step from left to right
275 if (fx < fxmax && fx != 0) {
279 } else if (fiy != fiymax) {
282 // get y-position of next row (yc), xc not used here
283 GetPadCxy(fix,fiy,xc,yc);
284 // get x-pad coordiante for first pad in row (fix)
285 GetPadIxy(fxmin,yc,fix,iyc);
287 printf("\n Error: Stepping outside integration region\n ");
289 GetPadCxy(fix,fiy,fx,fy);
290 fSector=Sector(fix,fiy);
292 (fSector ==-1 || fSector==0))
296 Int_t AliMUONSegmentationV01::MorePads()
297 // Stopping condition for the iterator over pads
299 // Are there more pads in the integration region
301 if ((fx >= fxmax && fiy >= fiymax) || fy==0) {
308 void AliMUONSegmentationV01::
309 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
311 // Returns integration limits for current pad
313 x1=fxhit-fx-Dpx(fSector)/2.;
315 y1=fyhit-fy-Dpy(fSector)/2.;
319 void AliMUONSegmentationV01::
320 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
322 // Returns list of next neighbours for given Pad (iX, iY)
324 const Float_t epsilon=fDpy/1000;
327 Int_t ixx, iyy, isec1;
329 Int_t isec0=AliMUONSegmentationV01::Sector(iX,iY);
334 if (Xlist[i]==0) Xlist[i]++;
339 if (Xlist[i]==0) Xlist[i]--;
343 AliMUONSegmentationV01::GetPadCxy(iX,iY,x,y);
344 AliMUONSegmentationV01::GetPadIxy(x+epsilon,y+fDpy,ixx,iyy);
347 isec1=AliMUONSegmentationV01::Sector(ixx,iyy);
350 // no sector boundary crossing
356 } else if (isec1 < isec0) {
357 // finer segmentation
367 // coarser segmenation
369 if (TMath::Odd(iX-fNpxS[isec1-1][iY+1])) {
381 AliMUONSegmentationV01::GetPadCxy(iX,iY,x,y);
382 AliMUONSegmentationV01::GetPadIxy(x+epsilon,y-fDpy,ixx,iyy);
385 isec1=AliMUONSegmentationV01::Sector(ixx,iyy);
388 // no sector boundary crossing
396 } else if (isec1 < isec0) {
397 // finer segmentation
407 // coarser segmentation
409 if (TMath::Odd(iX-fNpxS[isec1-1][iY-1])) {
421 void AliMUONSegmentationV01::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y)
423 // Returns test point on the pad plane.
424 // Used during determination of the segmoid correction of the COG-method
427 x[0]=(fRSec[0]+fRSec[1])/2/TMath::Sqrt(2.);
429 x[1]=(fRSec[1]+fRSec[2])/2/TMath::Sqrt(2.);
431 x[2]=(fRSec[2]+fRSec[3])/2/TMath::Sqrt(2.);
435 void AliMUONSegmentationV01::Draw()
437 // Draws the segmentation zones
441 Float_t dx=0.95/fCx[3][1]/2;
442 Float_t dy=0.95/(Float_t(Npy()))/2;
447 for (Int_t iy=1; iy<Npy(); iy++)
449 for (Int_t isec=0; isec<4; isec++) {
454 x0=fCx[isec-1][iy]*dx;
459 box=new TBox(x0+xc,y0+yc,x1+xc,y1+yc);
460 box->SetFillColor(isec+1);
463 box=new TBox(-x1+xc,y0+yc,-x0+xc,y1+yc);
464 box->SetFillColor(isec+1);
467 box=new TBox(x0+xc,-y1+yc,x1+xc,-y0+yc);
468 box->SetFillColor(isec+1);
471 box=new TBox(-x1+xc,-y1+yc,-x0+xc,-y0+yc);
472 box->SetFillColor(isec+1);
477 void AliMUONSegmentationV01::SetCorrFunc(Int_t isec, TF1* func)
482 TF1* AliMUONSegmentationV01::CorrFunc(Int_t isec)
484 return (TF1*) (*fCorr)[isec];