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