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