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