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 **************************************************************************/
17 Revision 1.3 2000/06/29 12:34:09 morsch
18 AliMUONSegmentation class has been made independent of AliMUONChamber. This makes
19 it usable with any other geometry class. The link to the object to which it belongs is
20 established via an index. This assumes that there exists a global geometry manager
21 from which the pointer to the parent object can be obtained (in our case gAlice).
23 Revision 1.2 2000/06/15 07:58:48 morsch
24 Code from MUON-dev joined
26 Revision 1.1.2.2 2000/06/12 07:57:23 morsch
29 Revision 1.1.2.1 2000/06/09 21:30:33 morsch
30 AliMUONSegmentationV0 code from AliMUONSegResV0.cxx
34 #include "AliMUONSegmentationV0.h"
37 #include "AliMUONChamber.h"
41 ClassImp(AliMUONSegmentationV0)
42 AliMUONSegmentationV0::AliMUONSegmentationV0(const AliMUONSegmentationV0& segmentation)
44 // Dummy copy constructor
47 void AliMUONSegmentationV0::Init(Int_t chamber)
49 // Initialises member data of the segmentation from geometry data
52 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
53 AliMUONChamber* iChamber=&(pMUON->Chamber(chamber));
55 // Initialise maximum number of pads in x ans y
56 fNpx=(Int_t) (iChamber->ROuter()/fDpx+1);
57 fNpy=(Int_t) (iChamber->ROuter()/fDpy+1);
58 // Initialize inner and outer radius of the sensitive region
59 fRmin=iChamber->RInner();
60 fRmax=iChamber->ROuter();
66 Float_t AliMUONSegmentationV0::GetAnod(Float_t xhit)
68 // Returns for a hit position xhit the position of the nearest anode wire
69 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
73 void AliMUONSegmentationV0::SetPadSize(Float_t p1, Float_t p2)
80 void AliMUONSegmentationV0::
81 GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
83 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
85 ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx)-1;
86 iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy)-1;
87 if (iy > fNpy) iy= fNpy;
88 if (iy < -fNpy) iy=-fNpy;
89 if (ix > fNpx) ix= fNpx;
90 if (ix < -fNpx) ix=-fNpx;
92 void AliMUONSegmentationV0::
93 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
95 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
97 // Comments and Critics:
99 // The Pad(0,0) does not exist, this causes in the present version errors
100 // during iteration when used with hits close to zero.
101 // Since we have frame crosses at x=0 or y=0 this does not cause any problems
102 // Nevertheless, should be corrected in the next version !!
103 // The name fRmin is misleading although we use this version with
104 // a circular chamber geometry.
106 x = (ix>0) ? Float_t(ix*fDpx)-fDpx/2. : Float_t(ix*fDpx)+fDpx/2.;
107 y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)+fDpy/2.;
110 void AliMUONSegmentationV0::
111 SetHit(Float_t xhit, Float_t yhit)
114 // Sets virtual hit position, needed for evaluating pad response
115 // outside the tracking program
120 void AliMUONSegmentationV0::
121 SetPad(Int_t ix, Int_t iy)
124 // Sets virtual pad coordinates, needed for evaluating pad response
125 // outside the tracking program
126 GetPadC(ix,iy,fx,fy);
129 void AliMUONSegmentationV0::
130 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
132 // Initialises iteration over pads for charge distribution algorithm
135 // Find the wire position (center of charge distribution)
136 Float_t x0a=GetAnod(xhit);
140 // and take fNsigma*sigma around this center
141 Float_t x01=x0a - dx;
142 Float_t x02=x0a + dx;
143 Float_t y01=yhit - dy;
144 Float_t y02=yhit + dy;
146 // find the pads over which the charge distributes
147 GetPadI(x01,y01,fixmin,fiymin);
148 GetPadI(x02,y02,fixmax,fiymax);
150 // Set current pad to lower left corner
153 GetPadC(fix,fiy,fx,fy);
156 void AliMUONSegmentationV0::NextPad()
158 // Stepper for the iteration over pads
160 // Comments and Critics:
161 // Boundary crossing at x=0 or y=0 not correctly handled !
162 // Step to next pad in the integration region
166 } else if (fiy != fiymax) {
171 printf("\n Error: Stepping outside integration region\n ");
173 GetPadC(fix,fiy,fx,fy);
176 Int_t AliMUONSegmentationV0::MorePads()
177 // Stopping condition for the iterator over pads
179 // Are there more pads in the integration region ?
181 if (fix == fixmax && fiy == fiymax) {
189 void AliMUONSegmentationV0::SigGenInit(Float_t x,Float_t y,Float_t z)
192 // Initialises pad and wire position during stepping
195 GetPadI(x,y,fixt,fiyt);
196 fiwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
199 Int_t AliMUONSegmentationV0::SigGenCond(Float_t x,Float_t y,Float_t z)
201 // Signal generation condition during stepping
202 // 0: don't generate signal
203 // 1: generate signal
204 // Comments and critics:
206 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
207 // To correctly simulate the dependence of the spatial resolution on the angle
208 // of incidence signal must be generated for constant steps on
209 // the projection of the trajectory along the anode wire.
212 // Signal will be generated if particle crosses pad boundary or
213 // boundary between two wires.
215 GetPadI(x,y,ixt,iyt);
216 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
217 if ((ixt != fixt) || (iyt !=fiyt) || (iwt != fiwt)) {
223 void AliMUONSegmentationV0::
224 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
226 // Returns integration limits for current pad
234 void AliMUONSegmentationV0::
235 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
237 // Returns list of next neighbours for given Pad (iX, iY)
239 // Comments and critics
240 // "Diagonal" neighbours are not passed
241 // Is this ok when we search for local maxima ??
242 // No test whether neighbours have valid indices id performed
244 Xlist[0]=Xlist[1]=iX;
249 Ylist[2]=Ylist[3]=iY;
252 Float_t AliMUONSegmentationV0::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y
254 // Returns the square of the distance between 1 pad
255 // labelled by its Channel numbers and a coordinate
259 return (x-X)*(x-X) + (y-Y)*(y-Y);
263 void AliMUONSegmentationV0::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y)
265 // Returns test point on the pad plane.
266 // Used during determination of the segmoid correction of the COG-method
268 x[0]=(fRmax+fRmin)/2/TMath::Sqrt(2.);
272 void AliMUONSegmentationV0::Draw()
274 // Draws the segmentation zones
277 Float_t scale=0.95/fRmax/2.;
280 circle = new TArc(0.5,0.5,fRmax*scale,0.,360.);
281 circle->SetFillColor(2);
284 circle = new TArc(0.5,0.5,fRmin*scale,0.,360.);
285 circle->SetFillColor(1);
289 AliMUONSegmentationV0& AliMUONSegmentationV0::operator =(const AliMUONSegmentationV0 & rhs)
291 // Dummy assignment operator