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.6 2000/10/02 16:58:29 egangler
18 Cleaning of the code :
21 -> some useless includes removed or replaced by "class" statement
23 Revision 1.5 2000/07/13 16:19:44 fca
24 Mainly coding conventions + some small bug fixes
26 Revision 1.4 2000/07/03 11:54:57 morsch
27 AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
28 The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
30 Revision 1.3 2000/06/29 12:34:09 morsch
31 AliMUONSegmentation class has been made independent of AliMUONChamber. This makes
32 it usable with any other geometry class. The link to the object to which it belongs is
33 established via an index. This assumes that there exists a global geometry manager
34 from which the pointer to the parent object can be obtained (in our case gAlice).
36 Revision 1.2 2000/06/15 07:58:48 morsch
37 Code from MUON-dev joined
39 Revision 1.1.2.2 2000/06/12 07:57:23 morsch
42 Revision 1.1.2.1 2000/06/09 21:30:33 morsch
43 AliMUONSegmentationV0 code from AliMUONSegResV0.cxx
47 #include "AliMUONSegmentationV0.h"
50 #include "AliMUONChamber.h"
54 ClassImp(AliMUONSegmentationV0)
55 AliMUONSegmentationV0::AliMUONSegmentationV0(const AliMUONSegmentationV0& segmentation)
57 // Dummy copy constructor
60 void AliMUONSegmentationV0::Init(Int_t chamber)
62 // Initialises member data of the segmentation from geometry data
65 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
66 AliMUONChamber* iChamber=&(pMUON->Chamber(chamber));
68 // Initialise maximum number of pads in x ans y
69 fNpx=(Int_t) (iChamber->ROuter()/fDpx+1);
70 fNpy=(Int_t) (iChamber->ROuter()/fDpy+1);
71 // Initialize inner and outer radius of the sensitive region
72 fRmin=iChamber->RInner();
73 fRmax=iChamber->ROuter();
78 Float_t AliMUONSegmentationV0::GetAnod(Float_t xhit) const
80 // Returns for a hit position xhit the position of the nearest anode wire
81 Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
85 void AliMUONSegmentationV0::SetPadSize(Float_t p1, Float_t p2)
93 void AliMUONSegmentationV0::
94 GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
96 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
98 ix = (x>0)? Int_t(x/fDpx)+1 : Int_t(x/fDpx)-1;
99 iy = (y>0)? Int_t(y/fDpy)+1 : Int_t(y/fDpy)-1;
100 if (iy > fNpy) iy= fNpy;
101 if (iy < -fNpy) iy=-fNpy;
102 if (ix > fNpx) ix= fNpx;
103 if (ix < -fNpx) ix=-fNpx;
106 void AliMUONSegmentationV0::
107 GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
109 // Returns real coordinates (x,y) for given pad coordinates (ix,iy)
111 // Comments and Critics:
113 // The Pad(0,0) does not exist, this causes in the present version errors
114 // during iteration when used with hits close to zero.
115 // Since we have frame crosses at x=0 or y=0 this does not cause any problems
116 // Nevertheless, should be corrected in the next version !!
117 // The name fRmin is misleading although we use this version with
118 // a circular chamber geometry.
120 x = (ix>0) ? Float_t(ix*fDpx)-fDpx/2. : Float_t(ix*fDpx)+fDpx/2.;
121 y = (iy>0) ? Float_t(iy*fDpy)-fDpy/2. : Float_t(iy*fDpy)+fDpy/2.;
124 void AliMUONSegmentationV0::
125 SetHit(Float_t xhit, Float_t yhit)
128 // Sets virtual hit position, needed for evaluating pad response
129 // outside the tracking program
134 void AliMUONSegmentationV0::
135 SetPad(Int_t ix, Int_t iy)
138 // Sets virtual pad coordinates, needed for evaluating pad response
139 // outside the tracking program
140 GetPadC(ix,iy,fX,fY);
143 void AliMUONSegmentationV0::
144 FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
146 // Initialises iteration over pads for charge distribution algorithm
149 // Find the wire position (center of charge distribution)
150 Float_t x0a=GetAnod(xhit);
154 // and take fNsigma*sigma around this center
155 Float_t x01=x0a - dx;
156 Float_t x02=x0a + dx;
157 Float_t y01=yhit - dy;
158 Float_t y02=yhit + dy;
160 // find the pads over which the charge distributes
161 GetPadI(x01,y01,fIxmin,fIymin);
162 GetPadI(x02,y02,fIxmax,fIymax);
164 // Set current pad to lower left corner
167 GetPadC(fIx,fIy,fX,fY);
170 void AliMUONSegmentationV0::NextPad()
172 // Stepper for the iteration over pads
174 // Comments and Critics:
175 // Boundary crossing at x=0 or y=0 not correctly handled !
176 // Step to next pad in the integration region
180 } else if (fIy != fIymax) {
185 printf("\n Error: Stepping outside integration region\n ");
187 GetPadC(fIx,fIy,fX,fY);
190 Int_t AliMUONSegmentationV0::MorePads()
191 // Stopping condition for the iterator over pads
193 // Are there more pads in the integration region ?
195 if (fIx == fIxmax && fIy == fIymax) {
203 void AliMUONSegmentationV0::SigGenInit(Float_t x,Float_t y,Float_t z)
206 // Initialises pad and wire position during stepping
209 GetPadI(x,y,fIxt,fIyt);
210 fIwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
213 Int_t AliMUONSegmentationV0::SigGenCond(Float_t x,Float_t y,Float_t z)
215 // Signal generation condition during stepping
216 // 0: don't generate signal
217 // 1: generate signal
218 // Comments and critics:
220 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
221 // To correctly simulate the dependence of the spatial resolution on the angle
222 // of incidence signal must be generated for constant steps on
223 // the projection of the trajectory along the anode wire.
226 // Signal will be generated if particle crosses pad boundary or
227 // boundary between two wires.
229 GetPadI(x,y,ixt,iyt);
230 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
231 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
237 void AliMUONSegmentationV0::
238 IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
240 // Returns integration limits for current pad
248 void AliMUONSegmentationV0::
249 Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
251 // Returns list of next neighbours for given Pad (iX, iY)
253 // Comments and critics
254 // "Diagonal" neighbours are not passed
255 // Is this ok when we search for local maxima ??
256 // No test whether neighbours have valid indices id performed
258 Xlist[0]=Xlist[1]=iX;
263 Ylist[2]=Ylist[3]=iY;
266 Float_t AliMUONSegmentationV0::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y
268 // Returns the square of the distance between 1 pad
269 // labelled by its Channel numbers and a coordinate
273 return (x-X)*(x-X) + (y-Y)*(y-Y);
277 void AliMUONSegmentationV0::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y) const
279 // Returns test point on the pad plane.
280 // Used during determination of the segmoid correction of the COG-method
282 x[0]=(fRmax+fRmin)/2/TMath::Sqrt(2.);
286 void AliMUONSegmentationV0::Draw(const char *) const
288 // Draws the segmentation zones
291 Float_t scale=0.95/fRmax/2.;
294 circle = new TArc(0.5,0.5,fRmax*scale,0.,360.);
295 circle->SetFillColor(2);
298 circle = new TArc(0.5,0.5,fRmin*scale,0.,360.);
299 circle->SetFillColor(1);
303 AliMUONSegmentationV0& AliMUONSegmentationV0::operator =(const AliMUONSegmentationV0 & rhs)
305 // Dummy assignment operator