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