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.8 2000/10/03 21:48:07 morsch
19 Adopt to const declaration of some of the methods in AliSegmentation.
21 Revision 1.7 2000/10/02 21:28:09 fca
22 Removal of useless dependecies via forward declarations
24 Revision 1.6 2000/10/02 16:58:29 egangler
25 Cleaning of the code :
28 -> some useless includes removed or replaced by "class" statement
30 Revision 1.5 2000/07/13 16:19:44 fca
31 Mainly coding conventions + some small bug fixes
33 Revision 1.4 2000/07/03 11:54:57 morsch
34 AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
35 The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
37 Revision 1.3 2000/06/29 12:34:09 morsch
38 AliMUONSegmentation class has been made independent of AliMUONChamber. This makes
39 it usable with any other geometry class. The link to the object to which it belongs is
40 established via an index. This assumes that there exists a global geometry manager
41 from which the pointer to the parent object can be obtained (in our case gAlice).
43 Revision 1.2 2000/06/15 07:58:48 morsch
44 Code from MUON-dev joined
46 Revision 1.1.2.1 2000/06/09 21:37:30 morsch
47 AliMUONSegmentationV01 code from AliMUONSegResV01.cxx
52 /////////////////////////////////////////////////////
53 // Segmentation and Response classes version 01 //
54 /////////////////////////////////////////////////////
58 #include <TObjArray.h>
61 #include "AliMUONSegmentationV01.h"
66 //___________________________________________
67 ClassImp(AliMUONSegmentationV01)
69 AliMUONSegmentationV01::AliMUONSegmentationV01(const AliMUONSegmentationV01& segmentation)
71 // Dummy copy constructor
73 AliMUONSegmentationV01::AliMUONSegmentationV01()
75 // Default constructor
77 fRSec = new TArrayF(fNsec);
78 fNDiv = new TArrayI(fNsec);
79 fDpxD = new TArrayF(fNsec);
80 (*fRSec)[0]=(*fRSec)[1]=(*fRSec)[2]=(*fRSec)[3]=0;
81 (*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0;
82 (*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0;
83 fCorr = new TObjArray(3);
89 Float_t AliMUONSegmentationV01::Dpx(Int_t isec) const
92 // Returns x-pad size for given sector isec
93 Float_t dpx = (*fDpxD)[isec];
97 Float_t AliMUONSegmentationV01::Dpy(Int_t isec) const
100 // Returns y-pad size for given sector isec
104 void AliMUONSegmentationV01::SetSegRadii(Float_t r[4])
107 // Set the radii of the segmentation zones
108 for (Int_t i=0; i<4; i++) {
110 printf("\n R %d %f \n",i,(*fRSec)[i]);
116 void AliMUONSegmentationV01::SetPadDivision(Int_t ndiv[4])
119 // Defines the pad size perp. to the anode wire (y) for different sectors.
120 // Pad sizes are defined as integral fractions ndiv of a basis pad size
123 for (Int_t i=0; i<4; i++) {
125 printf("\n Ndiv %d %d \n",i,(*fNDiv)[i]);
131 void AliMUONSegmentationV01::Init(Int_t chamber)
134 // Fill the arrays fCx (x-contour) and fNpxS (ix-contour) for each sector
135 // These arrays help in converting from real to pad co-ordinates and
137 // This version approximates concentric segmentation zones
140 printf("\n Initialise segmentation v01 -- test !!!!!!!!!!!!!! \n");
141 fNpy=Int_t((*fRSec)[fNsec-1]/fDpy)+1;
143 (*fDpxD)[fNsec-1]=fDpx;
145 for (Int_t i=fNsec-2; i>=0; i--){
146 (*fDpxD)[i]=(*fDpxD)[fNsec-1]/(*fNDiv)[i];
147 printf("\n test ---dx %d %f \n",i,(*fDpxD)[i]);
151 // fill the arrays defining the pad segmentation boundaries
156 // loop over sections
157 for(isec=0; isec<fNsec; isec++) {
159 // loop over pads along the aode wires
160 for (Int_t iy=1; iy<=fNpy; iy++) {
162 Float_t x=iy*fDpy-fDpy/2;
163 if (x > (*fRSec)[isec]) {
167 ry=TMath::Sqrt((*fRSec)[isec]*(*fRSec)[isec]-x*x);
169 dnx= Int_t((ry-fCx[isec-1][iy])/(*fDpxD)[isec]);
170 if (isec < fNsec-1) {
171 if (TMath::Odd((Long_t)dnx)) dnx++;
173 fNpxS[isec][iy]=fNpxS[isec-1][iy]+dnx;
174 fCx[isec][iy]=fCx[isec-1][iy]+dnx*(*fDpxD)[isec];
175 } else if (isec == 1) {
176 dnx= Int_t((ry-fCx[isec-1][iy])/(*fDpxD)[isec]);
177 fNpxS[isec][iy]=fNpxS[isec-1][iy]+dnx;
178 add=4 - (fNpxS[isec][iy])%4;
179 if (add < 4) fNpxS[isec][iy]+=add;
180 dnx=fNpxS[isec][iy]-fNpxS[isec-1][iy];
181 fCx[isec][iy]=fCx[isec-1][iy]+dnx*(*fDpxD)[isec];
183 dnx=Int_t(ry/(*fDpxD)[isec]);
185 fCx[isec][iy]=dnx*(*fDpxD)[isec];
192 Int_t AliMUONSegmentationV01::Sector(Int_t ix, Int_t iy)
194 // Returns sector number for given pad position
196 Int_t absix=TMath::Abs(ix);
197 Int_t absiy=TMath::Abs(iy);
199 for (Int_t i=0; i<fNsec; i++) {
200 if (absix<=fNpxS[i][absiy]){
208 void AliMUONSegmentationV01::
209 GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
211 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
213 iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy)-1;
214 if (iy > fNpy) iy= fNpy;
215 if (iy < -fNpy) iy=-fNpy;
219 Float_t absx=TMath::Abs(x);
220 Int_t absiy=TMath::Abs(iy);
221 for (Int_t i=0; i < fNsec; i++) {
222 if (absx <= fCx[i][absiy]) {
228 ix= Int_t((absx-fCx[isec-1][absiy])/(*fDpxD)[isec])
229 +fNpxS[isec-1][absiy]+1;
230 } else if (isec == 0) {
231 ix= Int_t(absx/(*fDpxD)[isec])+1;
233 ix=fNpxS[fNsec-1][absiy]+1;
238 void AliMUONSegmentationV01::
239 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
241 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
243 y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)+fDpy/2.;
246 Int_t isec=AliMUONSegmentationV01::Sector(ix,iy);
248 Int_t absix=TMath::Abs(ix);
249 Int_t absiy=TMath::Abs(iy);
251 x=fCx[isec-1][absiy]+(absix-fNpxS[isec-1][absiy])*(*fDpxD)[isec];
252 x=(ix>0) ? x-(*fDpxD)[isec]/2 : -x+(*fDpxD)[isec]/2;
258 void AliMUONSegmentationV01::
259 SetPad(Int_t ix, Int_t iy)
262 // Sets virtual pad coordinates, needed for evaluating pad response
263 // outside the tracking program
264 GetPadC(ix,iy,fX,fY);
265 fSector=Sector(ix,iy);
269 void AliMUONSegmentationV01::
270 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
272 // Initialises iteration over pads for charge distribution algorithm
275 // Find the wire position (center of charge distribution)
276 Float_t x0a=GetAnod(xhit);
281 // and take fNsigma*sigma around this center
282 Float_t x01=x0a - dx;
283 Float_t x02=x0a + dx;
284 Float_t y01=yhit - dy;
285 Float_t y02=yhit + dy;
287 // find the pads over which the charge distributes
289 GetPadI(x01,y01,fIxmin,fIymin);
290 GetPadI(x02,y02,fIxmax,fIymax);
297 // Set current pad to lower left corner
298 if (fIxmax < fIxmin) fIxmax=fIxmin;
299 if (fIymax < fIymin) fIymax=fIymin;
302 GetPadC(fIx,fIy,fX,fY);
306 void AliMUONSegmentationV01::NextPad()
308 // Stepper for the iteration over pads
310 // Step to next pad in the integration region
312 // Step to next pad in integration region
316 // step from left to right
318 if (fX < fXmax && fX != 0) {
322 } else if (fIy != fIymax) {
325 // get y-position of next row (yc), xc not used here
326 GetPadC(fIx,fIy,xc,yc);
327 // get x-pad coordiante for first pad in row (fIx)
328 GetPadI(fXmin,yc,fIx,iyc);
333 GetPadC(fIx,fIy,fX,fY);
334 fSector=Sector(fIx,fIy);
336 (fSector ==-1 || fSector==0))
340 Int_t AliMUONSegmentationV01::MorePads()
341 // Stopping condition for the iterator over pads
343 // Are there more pads in the integration region
345 return (fIx != -1 || fIy != -1);
347 if ((fX >= fXmax && fIy >= fIymax) || fY==0) {
355 void AliMUONSegmentationV01::
356 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
358 // Returns integration limits for current pad
360 x1=fXhit-fX-Dpx(fSector)/2.;
362 y1=fYhit-fY-Dpy(fSector)/2.;
366 void AliMUONSegmentationV01::
367 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
369 // Returns list of next neighbours for given Pad (iX, iY)
371 const Float_t kEpsilon=fDpy/1000;
374 Int_t ixx, iyy, isec1;
376 Int_t isec0=AliMUONSegmentationV01::Sector(iX,iY);
381 if (Xlist[i]==0) Xlist[i]++;
386 if (Xlist[i]==0) Xlist[i]--;
390 AliMUONSegmentationV01::GetPadC(iX,iY,x,y);
391 AliMUONSegmentationV01::GetPadI(x+kEpsilon,y+fDpy,ixx,iyy);
394 isec1=AliMUONSegmentationV01::Sector(ixx,iyy);
397 // no sector boundary crossing
403 } else if (isec1 < isec0) {
404 // finer segmentation
414 // coarser segmenation
416 if (TMath::Odd(iX-fNpxS[isec1-1][iY+1])) {
428 AliMUONSegmentationV01::GetPadC(iX,iY,x,y);
429 AliMUONSegmentationV01::GetPadI(x+kEpsilon,y-fDpy,ixx,iyy);
432 isec1=AliMUONSegmentationV01::Sector(ixx,iyy);
435 // no sector boundary crossing
443 } else if (isec1 < isec0) {
444 // finer segmentation
454 // coarser segmentation
456 if (TMath::Odd(iX-fNpxS[isec1-1][iY-1])) {
468 void AliMUONSegmentationV01::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y) const
470 // Returns test point on the pad plane.
471 // Used during determination of the segmoid correction of the COG-method
474 x[0]=((*fRSec)[0]+(*fRSec)[1])/2/TMath::Sqrt(2.);
476 x[1]=((*fRSec)[1]+(*fRSec)[2])/2/TMath::Sqrt(2.);
478 x[2]=((*fRSec)[2]+(*fRSec)[3])/2/TMath::Sqrt(2.);
482 void AliMUONSegmentationV01::Draw(const char *) const
484 // Draws the segmentation zones
488 Float_t dx=0.95/fCx[3][1]/2;
489 Float_t dy=0.95/(Float_t(Npy()))/2;
494 for (Int_t iy=1; iy<Npy(); iy++)
496 for (Int_t isec=0; isec<4; isec++) {
501 x0=fCx[isec-1][iy]*dx;
506 box=new TBox(x0+xc,y0+yc,x1+xc,y1+yc);
507 box->SetFillColor(isec+1);
510 box=new TBox(-x1+xc,y0+yc,-x0+xc,y1+yc);
511 box->SetFillColor(isec+1);
514 box=new TBox(x0+xc,-y1+yc,x1+xc,-y0+yc);
515 box->SetFillColor(isec+1);
518 box=new TBox(-x1+xc,-y1+yc,-x0+xc,-y0+yc);
519 box->SetFillColor(isec+1);
524 void AliMUONSegmentationV01::SetCorrFunc(Int_t isec, TF1* func)
529 TF1* AliMUONSegmentationV01::CorrFunc(Int_t isec) const
531 return (TF1*) (*fCorr)[isec];
534 AliMUONSegmentationV01& AliMUONSegmentationV01::operator
535 =(const AliMUONSegmentationV01 & rhs)
537 // Dummy assignment operator