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