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.5 2000/07/13 16:19:44 fca
18 Mainly coding conventions + some small bug fixes
20 Revision 1.4 2000/07/03 11:54:57 morsch
21 AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
22 The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
24 Revision 1.3 2000/06/29 12:34:09 morsch
25 AliMUONSegmentation class has been made independent of AliMUONChamber. This makes
26 it usable with any other geometry class. The link to the object to which it belongs is
27 established via an index. This assumes that there exists a global geometry manager
28 from which the pointer to the parent object can be obtained (in our case gAlice).
30 Revision 1.2 2000/06/15 07:58:48 morsch
31 Code from MUON-dev joined
33 Revision 1.1.2.2 2000/06/12 07:57:23 morsch
36 Revision 1.1.2.1 2000/06/09 21:30:33 morsch
37 AliMUONSegmentationV0 code from AliMUONSegResV0.cxx
41 #include "AliMUONSegmentationV0.h"
44 #include "AliMUONChamber.h"
48 ClassImp(AliMUONSegmentationV0)
49 AliMUONSegmentationV0::AliMUONSegmentationV0(const AliMUONSegmentationV0& segmentation)
51 // Dummy copy constructor
54 void AliMUONSegmentationV0::Init(Int_t chamber)
56 // Initialises member data of the segmentation from geometry data
59 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
60 AliMUONChamber* iChamber=&(pMUON->Chamber(chamber));
62 // Initialise maximum number of pads in x ans y
63 fNpx=(Int_t) (iChamber->ROuter()/fDpx+1);
64 fNpy=(Int_t) (iChamber->ROuter()/fDpy+1);
65 // Initialize inner and outer radius of the sensitive region
66 fRmin=iChamber->RInner();
67 fRmax=iChamber->ROuter();
73 Float_t AliMUONSegmentationV0::GetAnod(Float_t xhit)
75 // Returns for a hit position xhit the position of the nearest anode wire
76 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
80 void AliMUONSegmentationV0::SetPadSize(Float_t p1, Float_t p2)
87 void AliMUONSegmentationV0::
88 GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
90 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
92 ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx)-1;
93 iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy)-1;
94 if (iy > fNpy) iy= fNpy;
95 if (iy < -fNpy) iy=-fNpy;
96 if (ix > fNpx) ix= fNpx;
97 if (ix < -fNpx) ix=-fNpx;
99 void AliMUONSegmentationV0::
100 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
102 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
104 // Comments and Critics:
106 // The Pad(0,0) does not exist, this causes in the present version errors
107 // during iteration when used with hits close to zero.
108 // Since we have frame crosses at x=0 or y=0 this does not cause any problems
109 // Nevertheless, should be corrected in the next version !!
110 // The name fRmin is misleading although we use this version with
111 // a circular chamber geometry.
113 x = (ix>0) ? Float_t(ix*fDpx)-fDpx/2. : Float_t(ix*fDpx)+fDpx/2.;
114 y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)+fDpy/2.;
117 void AliMUONSegmentationV0::
118 SetHit(Float_t xhit, Float_t yhit)
121 // Sets virtual hit position, needed for evaluating pad response
122 // outside the tracking program
127 void AliMUONSegmentationV0::
128 SetPad(Int_t ix, Int_t iy)
131 // Sets virtual pad coordinates, needed for evaluating pad response
132 // outside the tracking program
133 GetPadC(ix,iy,fX,fY);
136 void AliMUONSegmentationV0::
137 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
139 // Initialises iteration over pads for charge distribution algorithm
142 // Find the wire position (center of charge distribution)
143 Float_t x0a=GetAnod(xhit);
147 // and take fNsigma*sigma around this center
148 Float_t x01=x0a - dx;
149 Float_t x02=x0a + dx;
150 Float_t y01=yhit - dy;
151 Float_t y02=yhit + dy;
153 // find the pads over which the charge distributes
154 GetPadI(x01,y01,fIxmin,fIymin);
155 GetPadI(x02,y02,fIxmax,fIymax);
157 // Set current pad to lower left corner
160 GetPadC(fIx,fIy,fX,fY);
163 void AliMUONSegmentationV0::NextPad()
165 // Stepper for the iteration over pads
167 // Comments and Critics:
168 // Boundary crossing at x=0 or y=0 not correctly handled !
169 // Step to next pad in the integration region
173 } else if (fIy != fIymax) {
178 printf("\n Error: Stepping outside integration region\n ");
180 GetPadC(fIx,fIy,fX,fY);
183 Int_t AliMUONSegmentationV0::MorePads()
184 // Stopping condition for the iterator over pads
186 // Are there more pads in the integration region ?
188 if (fIx == fIxmax && fIy == fIymax) {
196 void AliMUONSegmentationV0::SigGenInit(Float_t x,Float_t y,Float_t z)
199 // Initialises pad and wire position during stepping
202 GetPadI(x,y,fIxt,fIyt);
203 fIwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
206 Int_t AliMUONSegmentationV0::SigGenCond(Float_t x,Float_t y,Float_t z)
208 // Signal generation condition during stepping
209 // 0: don't generate signal
210 // 1: generate signal
211 // Comments and critics:
213 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
214 // To correctly simulate the dependence of the spatial resolution on the angle
215 // of incidence signal must be generated for constant steps on
216 // the projection of the trajectory along the anode wire.
219 // Signal will be generated if particle crosses pad boundary or
220 // boundary between two wires.
222 GetPadI(x,y,ixt,iyt);
223 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
224 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
230 void AliMUONSegmentationV0::
231 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
233 // Returns integration limits for current pad
241 void AliMUONSegmentationV0::
242 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
244 // Returns list of next neighbours for given Pad (iX, iY)
246 // Comments and critics
247 // "Diagonal" neighbours are not passed
248 // Is this ok when we search for local maxima ??
249 // No test whether neighbours have valid indices id performed
251 Xlist[0]=Xlist[1]=iX;
256 Ylist[2]=Ylist[3]=iY;
259 Float_t AliMUONSegmentationV0::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y
261 // Returns the square of the distance between 1 pad
262 // labelled by its Channel numbers and a coordinate
266 return (x-X)*(x-X) + (y-Y)*(y-Y);
270 void AliMUONSegmentationV0::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y)
272 // Returns test point on the pad plane.
273 // Used during determination of the segmoid correction of the COG-method
275 x[0]=(fRmax+fRmin)/2/TMath::Sqrt(2.);
279 void AliMUONSegmentationV0::Draw(const char *)
281 // Draws the segmentation zones
284 Float_t scale=0.95/fRmax/2.;
287 circle = new TArc(0.5,0.5,fRmax*scale,0.,360.);
288 circle->SetFillColor(2);
291 circle = new TArc(0.5,0.5,fRmin*scale,0.,360.);
292 circle->SetFillColor(1);
296 AliMUONSegmentationV0& AliMUONSegmentationV0::operator =(const AliMUONSegmentationV0 & rhs)
298 // Dummy assignment operator