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