]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSegmentationV0.cxx
New class replacing AliCluster
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentationV0.cxx
CommitLineData
a9e2aefa 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15/*
16$Log$
c3eff6ad 17Revision 1.6 2000/10/02 16:58:29 egangler
18Cleaning of the code :
19-> coding conventions
20-> void Streamers
21-> some useless includes removed or replaced by "class" statement
22
ecfa008b 23Revision 1.5 2000/07/13 16:19:44 fca
24Mainly coding conventions + some small bug fixes
25
ef42d733 26Revision 1.4 2000/07/03 11:54:57 morsch
27AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
28The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
29
a30a000f 30Revision 1.3 2000/06/29 12:34:09 morsch
31AliMUONSegmentation class has been made independent of AliMUONChamber. This makes
32it usable with any other geometry class. The link to the object to which it belongs is
33established via an index. This assumes that there exists a global geometry manager
34from which the pointer to the parent object can be obtained (in our case gAlice).
35
d81db581 36Revision 1.2 2000/06/15 07:58:48 morsch
37Code from MUON-dev joined
38
a9e2aefa 39Revision 1.1.2.2 2000/06/12 07:57:23 morsch
40include TMath.h
41
42Revision 1.1.2.1 2000/06/09 21:30:33 morsch
43AliMUONSegmentationV0 code from AliMUONSegResV0.cxx
44
45*/
46
47#include "AliMUONSegmentationV0.h"
48#include "TArc.h"
49#include "TMath.h"
50#include "AliMUONChamber.h"
d81db581 51#include "AliRun.h"
52#include "AliMUON.h"
a9e2aefa 53
54ClassImp(AliMUONSegmentationV0)
55 AliMUONSegmentationV0::AliMUONSegmentationV0(const AliMUONSegmentationV0& segmentation)
56{
57// Dummy copy constructor
58}
59
d81db581 60 void AliMUONSegmentationV0::Init(Int_t chamber)
a9e2aefa 61{
62// Initialises member data of the segmentation from geometry data
63// owned by Chamber
64//
d81db581 65 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
66 AliMUONChamber* iChamber=&(pMUON->Chamber(chamber));
67
a9e2aefa 68// Initialise maximum number of pads in x ans y
d81db581 69 fNpx=(Int_t) (iChamber->ROuter()/fDpx+1);
70 fNpy=(Int_t) (iChamber->ROuter()/fDpy+1);
a9e2aefa 71// Initialize inner and outer radius of the sensitive region
d81db581 72 fRmin=iChamber->RInner();
73 fRmax=iChamber->ROuter();
a9e2aefa 74 fCorr=0;
a9e2aefa 75}
76
77
c3eff6ad 78Float_t AliMUONSegmentationV0::GetAnod(Float_t xhit) const
a9e2aefa 79{
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;
82 return fWireD*wire;
83}
84
85void AliMUONSegmentationV0::SetPadSize(Float_t p1, Float_t p2)
86{
87// Sets the padsize
88//
89 fDpx=p1;
90 fDpy=p2;
91}
c3eff6ad 92
a9e2aefa 93void AliMUONSegmentationV0::
c3eff6ad 94 GetPadI(Float_t x, Float_t y, Int_t &ix, Int_t &iy)
a9e2aefa 95{
96// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
97//
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;
104}
c3eff6ad 105
a9e2aefa 106void AliMUONSegmentationV0::
c3eff6ad 107GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y)
a9e2aefa 108{
109// Returns real coordinates (x,y) for given pad coordinates (ix,iy)
110//
111// Comments and Critics:
112
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.
119
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.;
122}
123
124void AliMUONSegmentationV0::
125SetHit(Float_t xhit, Float_t yhit)
126{
127 //
128 // Sets virtual hit position, needed for evaluating pad response
129 // outside the tracking program
ecfa008b 130 fXhit=xhit;
131 fYhit=yhit;
a9e2aefa 132}
133
134void AliMUONSegmentationV0::
135SetPad(Int_t ix, Int_t iy)
136{
137 //
138 // Sets virtual pad coordinates, needed for evaluating pad response
139 // outside the tracking program
ecfa008b 140 GetPadC(ix,iy,fX,fY);
a9e2aefa 141}
142
143void AliMUONSegmentationV0::
144FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy)
145{
146// Initialises iteration over pads for charge distribution algorithm
147//
148 //
149 // Find the wire position (center of charge distribution)
150 Float_t x0a=GetAnod(xhit);
ecfa008b 151 fXhit=x0a;
152 fYhit=yhit;
a9e2aefa 153 //
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;
159 //
160 // find the pads over which the charge distributes
ecfa008b 161 GetPadI(x01,y01,fIxmin,fIymin);
162 GetPadI(x02,y02,fIxmax,fIymax);
a9e2aefa 163 //
164 // Set current pad to lower left corner
ecfa008b 165 fIx=fIxmin;
166 fIy=fIymin;
167 GetPadC(fIx,fIy,fX,fY);
a9e2aefa 168}
169
170void AliMUONSegmentationV0::NextPad()
171{
172 // Stepper for the iteration over pads
173 //
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
ecfa008b 177 if (fIx != fIxmax) {
178 if (fIx==-1) fIx++;
179 fIx++;
180 } else if (fIy != fIymax) {
181 fIx=fIxmin;
182 if (fIy==-1) fIy++;
183 fIy++;
a9e2aefa 184 } else {
185 printf("\n Error: Stepping outside integration region\n ");
186 }
ecfa008b 187 GetPadC(fIx,fIy,fX,fY);
a9e2aefa 188}
189
190Int_t AliMUONSegmentationV0::MorePads()
191// Stopping condition for the iterator over pads
192//
193// Are there more pads in the integration region ?
194{
ecfa008b 195 if (fIx == fIxmax && fIy == fIymax) {
a9e2aefa 196 return 0;
197 } else {
198 return 1;
199
200 }
201}
202
203void AliMUONSegmentationV0::SigGenInit(Float_t x,Float_t y,Float_t z)
204{
205//
206// Initialises pad and wire position during stepping
ecfa008b 207 fXt =x;
208 fYt =y;
209 GetPadI(x,y,fIxt,fIyt);
210 fIwt= (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
a9e2aefa 211}
c3eff6ad 212
213Int_t AliMUONSegmentationV0::SigGenCond(Float_t x,Float_t y,Float_t z)
a9e2aefa 214{
215// Signal generation condition during stepping
216// 0: don't generate signal
217// 1: generate signal
218// Comments and critics:
219
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.
224
225//
226// Signal will be generated if particle crosses pad boundary or
227// boundary between two wires.
228 Int_t ixt, iyt;
a30a000f 229 GetPadI(x,y,ixt,iyt);
a9e2aefa 230 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
ecfa008b 231 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
a9e2aefa 232 return 1;
233 } else {
234 return 0;
235 }
236}
237void AliMUONSegmentationV0::
238IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
239{
240// Returns integration limits for current pad
241//
ecfa008b 242 x1=fXhit-fX-fDpx/2.;
a9e2aefa 243 x2=x1+fDpx;
ecfa008b 244 y1=fYhit-fY-fDpy/2.;
a9e2aefa 245 y2=y1+fDpy;
246}
247
248void AliMUONSegmentationV0::
c3eff6ad 249Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10])
a9e2aefa 250{
251// Returns list of next neighbours for given Pad (iX, iY)
252//
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
257 *Nlist=4;
258 Xlist[0]=Xlist[1]=iX;
259 Xlist[2]=iX-1;
260 Xlist[3]=iX+1;
261 Ylist[0]=iY-1;
262 Ylist[1]=iY+1;
263 Ylist[2]=Ylist[3]=iY;
264}
265
266Float_t AliMUONSegmentationV0::Distance2AndOffset(Int_t iX, Int_t iY, Float_t X, Float_t Y
267, Int_t *dummy)
268// Returns the square of the distance between 1 pad
269// labelled by its Channel numbers and a coordinate
270{
271 Float_t x,y;
a30a000f 272 GetPadC(iX,iY,x,y);
a9e2aefa 273 return (x-X)*(x-X) + (y-Y)*(y-Y);
274}
275
276
c3eff6ad 277void AliMUONSegmentationV0::GiveTestPoints(Int_t &n, Float_t *x, Float_t *y) const
a9e2aefa 278{
279// Returns test point on the pad plane.
280// Used during determination of the segmoid correction of the COG-method
281 n=1;
282 x[0]=(fRmax+fRmin)/2/TMath::Sqrt(2.);
283 y[0]=x[0];
284}
285
c3eff6ad 286void AliMUONSegmentationV0::Draw(const char *) const
a9e2aefa 287{
288// Draws the segmentation zones
289//
290 TArc *circle;
291 Float_t scale=0.95/fRmax/2.;
292
293
294 circle = new TArc(0.5,0.5,fRmax*scale,0.,360.);
295 circle->SetFillColor(2);
296 circle->Draw();
297
298 circle = new TArc(0.5,0.5,fRmin*scale,0.,360.);
299 circle->SetFillColor(1);
300 circle->Draw();
301}
302
303AliMUONSegmentationV0& AliMUONSegmentationV0::operator =(const AliMUONSegmentationV0 & rhs)
304{
305// Dummy assignment operator
306 return *this;
307}