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