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