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